浏览代码

薪资代码

yuansh 8 月之前
父节点
当前提交
c7d313e78a

+ 132 - 4
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/salary/controller/SalaryManagementController.java

@@ -463,6 +463,105 @@ public class SalaryManagementController {
         return this.exportXlsView(request, salaryManagement);
     }
 
+    public SalaryManagementDetail changePar(List<SalaryManagementDetail> exportList){
+        SalaryManagementDetail userParams = new SalaryManagementDetail();
+
+        BigDecimal wages = new BigDecimal("0");//基本薪资
+        BigDecimal phoneBill = new BigDecimal("0");//话费补贴
+        BigDecimal lunch = new BigDecimal("0");//午餐补贴
+        BigDecimal housingSubsidies = new BigDecimal("0");//住房补贴
+        BigDecimal transportation = new BigDecimal("0");//交通补贴
+        BigDecimal fullAttendance = new BigDecimal("0");//全勤奖
+        BigDecimal totalPayable = new BigDecimal("0");//合计应发String
+
+        BigDecimal socialSecurity = new BigDecimal("0");//社保
+        BigDecimal accumulationFund = new BigDecimal("0");//公积金
+        BigDecimal personalTax = new BigDecimal("0");//个税
+
+        BigDecimal latenessCost = new BigDecimal("0");//迟到扣费
+        BigDecimal personalCost = new BigDecimal("0");//事假扣费
+        BigDecimal sickCost = new BigDecimal("0");//病假扣费
+        BigDecimal marriageCost = new BigDecimal("0");//婚假扣费
+        BigDecimal funeralCost = new BigDecimal("0");//丧假扣费
+
+        BigDecimal endowmentInsurance = new BigDecimal("0");//养老保险
+        BigDecimal unemploymentInsurance = new BigDecimal("0");//失业保险
+        BigDecimal medicalInsurance = new BigDecimal("0");//医疗保险
+
+//        BigDecimal overtimePay = new BigDecimal("0");//加班工资
+//        BigDecimal yearSalary = new BigDecimal("0");//年休工资
+
+        BigDecimal totalDeduction = new BigDecimal("0");//合计应扣
+        BigDecimal actualOccurrence = new BigDecimal("0");//实发合计String
+
+        for(SalaryManagementDetail d: exportList){
+
+            endowmentInsurance = endowmentInsurance.add(d.getEndowmentInsurance() == null ? BigDecimal.ZERO : d.getEndowmentInsurance());
+            unemploymentInsurance = unemploymentInsurance.add(d.getUnemploymentInsurance() == null ? BigDecimal.ZERO : d.getUnemploymentInsurance());
+            medicalInsurance = medicalInsurance.add(d.getMedicalInsurance() == null ? BigDecimal.ZERO : d.getMedicalInsurance());
+
+            phoneBill = phoneBill.add(d.getPhoneBill() == null ? BigDecimal.ZERO : d.getPhoneBill());
+            lunch = lunch.add(d.getLunch() == null ? BigDecimal.ZERO : d.getLunch());
+            housingSubsidies = housingSubsidies.add(d.getHousingSubsidies() == null ? BigDecimal.ZERO : d.getHousingSubsidies());
+            transportation = transportation.add(d.getTransportation() == null ? BigDecimal.ZERO : d.getTransportation());
+            fullAttendance = fullAttendance.add(d.getFullAttendance() == null ? BigDecimal.ZERO : d.getFullAttendance());
+            socialSecurity = socialSecurity.add(d.getSocialSecurity() == null ? BigDecimal.ZERO : d.getSocialSecurity());
+            accumulationFund = accumulationFund.add(d.getAccumulationFund() == null ? BigDecimal.ZERO : d.getAccumulationFund());
+            personalTax = personalTax.add(d.getPersonalTax() == null ? BigDecimal.ZERO : d.getPersonalTax());
+            latenessCost = latenessCost.add(d.getLatenessCost() == null ? BigDecimal.ZERO : d.getLatenessCost());
+            personalCost = personalCost.add(d.getPersonalCost() == null ? BigDecimal.ZERO : d.getPersonalCost());
+            sickCost = sickCost.add(d.getSickCost() == null ? BigDecimal.ZERO : d.getSickCost());
+            marriageCost = marriageCost.add(d.getMarriageCost() == null ? BigDecimal.ZERO : d.getMarriageCost());
+            funeralCost = funeralCost.add(d.getFuneralCost() == null ? BigDecimal.ZERO : d.getFuneralCost());
+
+            //合计应扣
+            totalDeduction = totalDeduction.add(d.getTotalDeduction() == null ? BigDecimal.ZERO : d.getTotalDeduction());
+
+            //totalPayable 合计应发
+            String hisTotalPayable = d.getTotalPayable();
+
+            BigDecimal hisTotalPayableNew = new BigDecimal(hisTotalPayable);
+            totalPayable = totalPayable.add(hisTotalPayableNew);
+
+            //actualOccurrence 实发合计
+            String hisActualOccurrence = d.getActualOccurrence();
+            BigDecimal hisActualOccurrenceNew = new BigDecimal(hisActualOccurrence);
+            actualOccurrence = actualOccurrence.add(hisActualOccurrenceNew);
+
+            //wages 基本工资
+            String hiswages = d.getWages();
+            BigDecimal hiswagesNew = new BigDecimal(hiswages);
+            wages = wages.add(hiswagesNew);
+
+        }
+        userParams.setEndowmentInsurance(endowmentInsurance);
+        userParams.setUnemploymentInsurance(unemploymentInsurance);
+        userParams.setMedicalInsurance(medicalInsurance);
+
+        userParams.setPhoneBill(phoneBill);
+        userParams.setLunch(lunch);
+        userParams.setHousingSubsidies(housingSubsidies);
+        userParams.setTransportation(transportation);
+        userParams.setFullAttendance(fullAttendance);
+//        userParams.setOvertimePay(overtimePay.add(userParams.getOvertimePay() == null ? BigDecimal.ZERO : userParams.getOvertimePay()));
+//        userParams.setYearSalary(yearSalary.add(userParams.getYearSalary() == null ? BigDecimal.ZERO : userParams.getYearSalary()));
+
+        userParams.setTotalPayable(totalPayable.toString());
+        userParams.setSocialSecurity(socialSecurity);
+        userParams.setAccumulationFund(accumulationFund);
+        userParams.setPersonalTax(personalTax);
+        userParams.setLatenessCost(latenessCost);
+        userParams.setPersonalCost(personalCost);
+        userParams.setSickCost(sickCost);
+        userParams.setMarriageCost(marriageCost);
+        userParams.setFuneralCost(funeralCost);
+        userParams.setTotalDeduction(totalDeduction);
+        userParams.setActualOccurrence(actualOccurrence.toString());
+        userParams.setWages(wages.toString());
+
+        return userParams;
+    }
+
     protected ModelAndView exportXlsView(HttpServletRequest request, SalaryManagement object) {
         // Step.1 组装查询条件
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
@@ -475,11 +574,21 @@ public class SalaryManagementController {
         try {
 
             if (type.equals("月度工资单")) {
+
+                ModelAndView mv1 = new ModelAndView(new JeecgTemplateExcelView());
+
                 title = "月度工资单";
                 List<SalaryManagementDetail> exportList = salaryManagementDetailService.selectByMainId(object.getId(), null);
                 exportList.removeIf(item -> item.getActualOccurrence().equals("nghotxDTNyeHgH0mlfbJig==") || item.getActualOccurrence().equals("HV3ndEx8HV9kd1WNbxLgwg=="));
 
+                SalaryManagementDetail userParams = new SalaryManagementDetail();
+
+                String orgName = null;
+                String yearName = null;
                 for (SalaryManagementDetail o : exportList) {
+                    orgName = o.getOrgName();
+                    yearName = o.getYearWithMonth();
+
                     String actualOccurrence = o.getActualOccurrence();
                     String wages = o.getWages();
                     String totalPayable = o.getTotalPayable();
@@ -494,11 +603,30 @@ public class SalaryManagementController {
                     }
                 }
 
-                mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
-                mv.addObject(NormalExcelConstants.CLASS, SalaryManagementDetail.class);
+                userParams = changePar(exportList);
+                userParams.setOrgName(orgName);
+                userParams.setYearWithMonth(yearName);
 
-                mv.addObject(NormalExcelConstants.FILE_NAME, title); //此处设置的filename无效 ,前端会重更新设置一下
-                mv.addObject(NormalExcelConstants.PARAMS, new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title));
+                String head = yearName+orgName+"工资单";
+                userParams.setName(head);
+
+                Map map = JSON.parseObject(JSON.toJSONString(userParams), Map.class);
+                map.put("list", exportList);
+                TemplateExportParams params = new TemplateExportParams();
+                params.setTemplateUrl("D:\\service\\oa\\工资单下载模板.xls");
+//                params.setTemplateUrl("D:\\工资单下载模板.xls");
+
+                mv1.addObject(TemplateExcelConstants.PARAMS, params);
+                mv1.addObject(TemplateExcelConstants.MAP_DATA, map);
+                mv1.addObject(NormalExcelConstants.FILE_NAME, "导出数据");
+
+                return mv1;
+
+//                mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
+//                mv.addObject(NormalExcelConstants.CLASS, SalaryManagementDetail.class);
+//
+//                mv.addObject(NormalExcelConstants.FILE_NAME, title); //此处设置的filename无效 ,前端会重更新设置一下
+//                mv.addObject(NormalExcelConstants.PARAMS, new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title));
 
             } else if (type.equals("加班工资单")) {
                 title = "加班工资单";

+ 10 - 0
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/salary/entity/SalaryManagementDetail.java

@@ -2,12 +2,15 @@ package org.jeecg.modules.salary.entity;
 
 import java.io.Serializable;
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import org.springframework.format.annotation.DateTimeFormat;
 import org.jeecgframework.poi.excel.annotation.Excel;
+
+import java.math.BigDecimal;
 import java.util.Date;
 
 /**
@@ -122,4 +125,11 @@ public class SalaryManagementDetail implements Serializable {
 	private java.lang.String yearWithMonth;
 	/**版本*/
 	private String version;
+
+	@TableField(exist = false)
+	private BigDecimal endowmentInsurance;//养老保险
+	@TableField(exist = false)
+	private BigDecimal unemploymentInsurance;//失业保险
+	@TableField(exist = false)
+	private BigDecimal medicalInsurance;//医疗保险
 }

+ 8 - 5
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/salary/mapper/xml/SalaryManagementDetailMapper.xml

@@ -10,15 +10,18 @@
 	</delete>
 	
 	<select id="selectByMainId" parameterType="java.lang.String" resultType="org.jeecg.modules.salary.entity.SalaryManagementDetail">
-		SELECT * 
-		FROM  salary_management_detail
+		SELECT a.*,b.endowment_insurance,b.unemployment_insurance,b.medical_insurance
+		FROM  salary_management_detail a
+
+		left join salary_attendance_detail b on a.user_id = b.user_id and a.year_with_month = b.year_with_month and b.del_flag = 0
+
 		WHERE
-			 head_id = #{id} and del_flag=0
+			a.head_id = #{id} and a.del_flag=0
 		<if test="name != null and name != ''">
-			AND name LIKE '%${name}%'
+			AND a.name LIKE '%${name}%'
 		</if>
 
-		order by substring_index(code, '-', 1) + 0 ASC,code
+		order by substring_index(a.code, '-', 1) + 0 ASC,a.code
 	</select>
 
 	<select id="selectByUser" parameterType="java.lang.String" resultType="org.jeecg.modules.salary.entity.SalaryManagementDetail">