瀏覽代碼

月工资条调整

dzx 11 月之前
父節點
當前提交
df9e868a55

+ 15 - 11
src/main/java/com/xjrsoft/module/personnel/service/impl/BasePersonnelLabourCapitalServiceImpl.java

@@ -1,11 +1,11 @@
 package com.xjrsoft.module.personnel.service.impl;
 
 import cn.dev33.satoken.stp.StpUtil;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseServiceImpl;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
 import com.xjrsoft.module.organization.entity.User;
 import com.xjrsoft.module.organization.service.IUserService;
 import com.xjrsoft.module.personnel.dto.BasePersonnelLabourCapitalMonthPageDto;
@@ -23,9 +23,8 @@ import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.Objects;
 import java.util.stream.Collectors;
 
@@ -50,15 +49,15 @@ public class BasePersonnelLabourCapitalServiceImpl extends MPJBaseServiceImpl<Ba
         User user = userService.getById(userId);
         dto.setJobNumber(user.getUserName());
         Page<BasePersonnelLabourCapitalMonthPageVo> resultPage = labourCapitalMapper.getMonthPage(page, dto);
-
+        JsonParser parser = new JsonParser();
         for (BasePersonnelLabourCapitalMonthPageVo record : resultPage.getRecords()) {
-            JSONObject extendJsonObj = JSON.parseObject(record.getPendingJson());
-            Map<String, Object> newDict = new HashMap<>();
+            JsonObject extendJsonObj = parser.parse(record.getPendingJson()).getAsJsonObject();
+            LinkedHashMap<String, Object> newDict = new LinkedHashMap<>();
 
             for (String key : extendJsonObj.keySet()) {
-                String bpName = getBpName(key);
+                String bpName = getBpName(record.getLabourCapitalId(), key);
                 if (bpName != null) {
-                    newDict.put(bpName, extendJsonObj.getString(key));
+                    newDict.put(bpName, extendJsonObj.get(key).isJsonNull()?"-":extendJsonObj.get(key).getAsString());
                 }
             }
 
@@ -76,8 +75,13 @@ public class BasePersonnelLabourCapitalServiceImpl extends MPJBaseServiceImpl<Ba
         return labourCapitalMapper.getYearPage(page, dto);
     }
 
-    private String getBpName(String columnNumber) {
-        List<BasePersonnelLabourCapitalTitle> bpTitles = capitalTitleMapper.selectList(Wrappers.<BasePersonnelLabourCapitalTitle>lambdaQuery().eq(BasePersonnelLabourCapitalTitle::getColumnNumber, columnNumber));
+    private String getBpName(Long labourCapitalId, String columnNumber) {
+        List<BasePersonnelLabourCapitalTitle> bpTitles = capitalTitleMapper.selectList(
+                Wrappers.<BasePersonnelLabourCapitalTitle>lambdaQuery()
+                        .eq(BasePersonnelLabourCapitalTitle::getColumnNumber, columnNumber)
+                        .eq(BasePersonnelLabourCapitalTitle::getLabourCapitalId, labourCapitalId)
+                        .orderByDesc(BasePersonnelLabourCapitalTitle::getRowsNumber)
+        );
         if (bpTitles != null && !bpTitles.isEmpty()) {
             return bpTitles.get(0).getName();
         } else {

+ 5 - 1
src/main/java/com/xjrsoft/module/personnel/vo/BasePersonnelLabourCapitalMonthPageVo.java

@@ -5,6 +5,7 @@ import com.alibaba.excel.annotation.write.style.ContentStyle;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.util.LinkedHashMap;
 import java.util.Map;
 
 /**
@@ -43,7 +44,7 @@ public class BasePersonnelLabourCapitalMonthPageVo {
     @ContentStyle(dataFormat = 49)
     @ExcelProperty("月工资明细")
     @ApiModelProperty("月工资明细")
-    private Map<String, Object> dict;
+    private LinkedHashMap<String, Object> dict;
 
     @ContentStyle(dataFormat = 49)
     @ExcelProperty("月份")
@@ -54,4 +55,7 @@ public class BasePersonnelLabourCapitalMonthPageVo {
     @ExcelProperty("年份")
     @ApiModelProperty("年份")
     private int year;
+
+    @ApiModelProperty("年份")
+    private Long labourCapitalId;
 }

+ 2 - 1
src/main/resources/mapper/personnel/BasePersonnelLabourCapitalMapper.xml

@@ -11,7 +11,8 @@
             t1.name,
             d.name as dept,
             t1.amount_to as amount,
-            t1.extend_json as pendingJson
+            t1.extend_json as pendingJson,
+            t1.labour_capital_id
         FROM
             base_personnel_labour_capital t
                 LEFT JOIN base_personnel_labour_capital_data t1 ON t1.labour_capital_id = t.id