فهرست منبع

Merge remote-tracking branch 'origin/master'

zhaoxian 2 سال پیش
والد
کامیت
b4556c0ff8

+ 5 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/MaterialParameterMapper.java

@@ -5,6 +5,8 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 /**
  * 素材归属标
  *
@@ -18,4 +20,7 @@ public interface MaterialParameterMapper extends BaseMapper<MaterialParameter> {
 
     JSONObject getByteDanceMaterialTotalCharge(@Param("signature") String signature);
 
+    List<JSONObject> getKuaiShouVideoCostList(@Param("md5List") List<String> md5List);
+
+    List<JSONObject> getBytedanceVideoCostList(List<String> md5List);
 }

+ 29 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/xml/MaterialParameterMapper.xml

@@ -17,4 +17,33 @@
         FROM application.bytedance_material_video_report_daily_dw
         WHERE signature = #{signature}
     </select>
+    <select id="getKuaiShouVideoCostList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        signature,
+        sum(charge) as charges
+        FROM application.kuaishou_material_video_report_daily_dw
+        WHERE signature
+        in
+        <foreach item="md5" index="index" collection="md5List"
+                 open="(" separator="," close=")">
+            #{md5}
+        </foreach>
+        group by signature;
+
+
+    </select>
+    <select id="getBytedanceVideoCostList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        signature,
+        sum(cost) as charges
+        FROM application.bytedance_material_video_report_daily_dw
+        WHERE signature
+        in
+        <foreach item="md5" index="index" collection="md5List"
+                 open="(" separator="," close=")">
+            #{md5}
+        </foreach>
+        group by signature;
+
+    </select>
 </mapper>

+ 38 - 14
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java

@@ -986,28 +986,16 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
         List<MaterialInfo> dailyList = materialInfoMapper.getListByParams(tagCode, type, status, materialName, code, startDate, endDate, userId, projectIds, ascription, clipId, shotId, planId, leaderName, offlineFlag, syncKuaishou, syncBytedance, materialInnovate);
         List<MaterialInfo> setList = new ArrayList<>();
         PageInfo<MaterialInfo> pageInfo = new PageInfo<>(dailyList);
+        List<String> md5List = new ArrayList<>();
         if (!dailyList.isEmpty()) {
             for (MaterialInfo info : dailyList) {
                 MaterialInfo materialInfo = materialInfoMapper.selectById(info.getId());
+                md5List.add(materialInfo.getCode());
                 materialInfo.setSlogansCount(info.getSlogansCount());
                 materialInfo.setOfflineFlag(info.getOfflineFlag());
                 materialInfo.setConfirmTime(info.getConfirmTime());
                 //素材名称为空 则使用素材id 同步失败
                 materialInfo.setMaterialName(Check.isNull(materialInfo.getMaterialName()) ? materialInfo.getId() : materialInfo.getMaterialName());
-                //统计快手总消耗数据
-                JSONObject kuaishous = materialParameterMapper.getMaterialTotalCharge(info.getCode());
-                if (!Check.isNull(kuaishous)) {
-                    materialInfo.setCost(kuaishous.getBigDecimal("charges"));
-                } else {
-                    materialInfo.setCost(new BigDecimal(0));
-                }
-                //统计抖音总消耗数据
-                JSONObject bytedances = materialParameterMapper.getByteDanceMaterialTotalCharge(info.getCode());
-                if (!Check.isNull(bytedances)) {
-                    materialInfo.setBytedanceCost(bytedances.getBigDecimal("charges"));
-                } else {
-                    materialInfo.setBytedanceCost(new BigDecimal(0));
-                }
                 Project project = projectService.getById(info.getProjectId());
                 if (!Check.isNull(project)) {
                     materialInfo.setMediaId(project.getMediaId());
@@ -1021,6 +1009,42 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
                 setList.add(materialInfo);
             }
         }
+        List<JSONObject> kuaiShouCostList = materialParameterMapper.getKuaiShouVideoCostList(md5List);
+        List<JSONObject> bytedanceCostList = materialParameterMapper.getBytedanceVideoCostList(md5List);
+        
+        Map<String,BigDecimal> kuaishouMap = new HashMap<>();
+        for (int i = 0; i < kuaiShouCostList.size(); i++) {
+            JSONObject jsonObject = kuaiShouCostList.get(i);
+            kuaishouMap.put(jsonObject.getString("signature"),jsonObject.getBigDecimal("charges"));
+        }
+
+        Map<String,BigDecimal> bytedanceMap = new HashMap<>();
+        for (int i = 0; i < bytedanceCostList.size(); i++) {
+            JSONObject jsonObject = bytedanceCostList.get(i);
+            bytedanceMap.put(jsonObject.getString("signature"),jsonObject.getBigDecimal("charges"));
+        }
+
+        for (int i = 0; i <setList.size() ; i++) {
+            MaterialInfo materialInfo = setList.get(i);
+            if(!Check.isNullMap(kuaishouMap)){
+                if (!Check.isNull(kuaishouMap.get(materialInfo.getCode()))) {
+                    materialInfo.setCost(kuaishouMap.get(materialInfo.getCode()));
+                } else {
+                    materialInfo.setCost(new BigDecimal(0));
+                }
+            }
+
+            if(!Check.isNullMap(bytedanceMap)){
+                if (!Check.isNull(bytedanceMap.get(materialInfo.getCode()))) {
+                    materialInfo.setBytedanceCost(bytedanceMap.get(materialInfo.getCode()));
+                } else {
+                    materialInfo.setBytedanceCost(new BigDecimal(0));
+                }
+            }
+
+        }
+
+
         pageInfo.setList(setList);
         result.put("data", pageInfo);
         ResultMapUtils.setResultMap(result, StatusCode.COMMON_SUCCESS);