Просмотр исходного кода

快手运营操作记录-自定义列

yangzian 2 лет назад
Родитель
Сommit
ea208b2dc2

+ 3 - 13
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/impl/KuaishouOperationRecordServiceImpl.java

@@ -18,6 +18,7 @@ import org.jeecg.ctop.material.mapper.MaterialStareMapper;
 import org.jeecg.ctop.material.service.IBossDataExhibitionService;
 import org.jeecg.ctop.material.service.KuaishouOperationRecordService;
 import org.jeecg.ctop.material.service.MaterialStareService;
+import org.jeecg.ctop.material.utils.FeidNotNullUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -108,19 +109,8 @@ public class KuaishouOperationRecordServiceImpl implements KuaishouOperationReco
         //查询 时报
         resultList = kuaishouOperationRecordMapper.getKuaishouUnitReportHourly(advertiserId,stratDate,endDate);
 
-        List<Map<String,Object>> list = new ArrayList<>();
-        for (int j = 0; j < resultList.size(); j++) {
-            KuaishouUnitReportHourlyPojo unitPojo = resultList.get(j);
-            Map unitMap = Check.parseObj2Map(unitPojo);
-            Map<String,Object> map = new HashMap<>();
-            for (int k =0;k < array.size();k++) {
-                JSONObject json = (JSONObject)array.get(k);
-                String fieldName = KuaishouUnitReportHourlyPojo.class.getDeclaredField(json.getString("dataIndex")).getName();
-                unitMap.get(fieldName);
-                map.put(fieldName, unitMap.get(fieldName));
-            }
-            list.add(map);
-        }
+        //自定义列数据
+        List<Map<String,Object>> list = FeidNotNullUtils.getCustomDateColumnList(resultList,array);
 
         return Result.successMsg("查询成功",list);
     }

+ 83 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/utils/FeidNotNullUtils.java

@@ -1,7 +1,17 @@
 package org.jeecg.ctop.material.utils;
 
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.poi.ss.formula.functions.T;
+import org.jeecg.ctop.material.constants.Check;
+import org.jeecg.ctop.material.entity.KuaishouUnitReportHourlyPojo;
+
 import java.lang.reflect.Field;
 import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * Administrator
@@ -34,4 +44,77 @@ public class FeidNotNullUtils {
         }
 
     }
+
+    /**
+     *
+     * @description: 获取自定义列数据
+     * @param dateList 数据详情 example:[
+     *         {
+     *
+     *             "realname": 2,
+     *             "roleType": 3,
+     *             "create_time": "2022-08-23 01:01:33",
+     *             "authName": "202206-智能托管",
+     *             "content_log": "测试测试测试123"
+     *         },{
+     *
+     *             "realname": 2,
+     *             "roleType": 3,
+     *             "create_time": "2022-08-23 01:01:33",
+     *             "authName": "20220619-促活-优选-RTA-sf_ks-ocpm-视频-低价-单品-0619-智能托管",
+     *             "content_log": "测试测试测试123"
+     *         }]
+     *
+     *
+     *
+     * @param array 自定义列信息
+     *              example: [{
+     *         "title":"账户名称",
+     *         "dataIndex":"authName",
+     *         "align":"center",
+     *         "key":"date",
+     *         "width":150,
+     *         "fixed":"left"
+     *     },{
+     *         "title":"运营人员",
+     *         "dataIndex":"realname",
+     *         "align":"center",
+     *         "width":150,
+     *         "fixed":"left"
+     *     }]
+     *
+     *  最终返回的结果数据 example:[{
+     *             "realname": 2,
+     *             "authName": "202206-智能托管"
+     *         },{
+     *             "realname": 2,
+     *             "authName": "20220619-促活-优选-RTA-sf_ks-ocpm-视频-低价-单品-0619-智能托管"
+     *         }]
+     *
+     *
+     * @return: java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
+     * @author: zianY
+     */
+    public static List<Map<String,Object>> getCustomDateColumnList(List dateList, JSONArray array) throws NoSuchFieldException{
+        List<Map<String,Object>> resultList = new ArrayList<>();
+        for (int j = 0; j < dateList.size(); j++) {
+            Object obj = dateList.get(j);
+            Map unitMap = Check.parseObj2Map(obj);
+            Map<String,Object> map = new HashMap<>();
+            for (int k =0;k < array.size();k++) {
+                JSONObject json = (JSONObject)array.get(k);
+                String fieldName = obj.getClass().getDeclaredField(json.getString("dataIndex")).getName();
+                unitMap.get(fieldName);
+                map.put(fieldName, unitMap.get(fieldName));
+            }
+            resultList.add(map);
+        }
+        return resultList;
+    }
+
+
+
+
+
+
 }