Bladeren bron

快手-盯盘-经理&个人(显示人员姓名)-end-master

yangzian 3 jaren geleden
bovenliggende
commit
63ce2c70f6

+ 1 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/MaterialStareMapper.java

@@ -57,6 +57,7 @@ public interface MaterialStareMapper {
     JSONObject getKuaiShouAccountTotalCost(@Param("accountId")Long accountId,@Param("statDate")Long statDate);
     //快手-运营 月总消耗
     JSONObject getKuaiShouAccountCostMonth(@Param("userId")String userId,@Param("statDate")Long statDate,@Param("endDate")Long endDate);
+    JSONObject getKuaiShouUserByUserId(@Param("userId")String userId);
 
     //快手 账户趋势图-时报
     List<JSONObject> getKuaiShouAccountInfoBrokenLineHour(@Param("type")String type,@Param("accountId")Long accountId,@Param("statDate")Long statDate,@Param("endDate")Long endDate);

+ 13 - 2
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/xml/MaterialStareMapper.xml

@@ -383,8 +383,7 @@
     <!-- 快手-运营 月总消耗 -->
     <select id="getKuaiShouAccountCostMonth" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
-            SUM( d.charge ) cost,
-            (SELECT realname from `jeecg-boot`.sys_user u where u.id = d.user_id) as userName
+            SUM( d.charge ) cost
         FROM
             application.kuaishou_account_report_daily_dw d
         <where>
@@ -403,6 +402,18 @@
     </select>
 
 
+    <!-- 用户 -->
+    <select id="getKuaiShouUserByUserId" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            realname as userName
+        FROM
+            `jeecg-boot`.sys_user
+        WHERE id = #{userId}
+
+    </select>
+
+
+
 
     <!-- 快手 账户趋势图-时报 -->
     <select id="getKuaiShouAccountInfoBrokenLineHour" resultType="com.alibaba.fastjson.JSONObject">

+ 22 - 7
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/impl/MaterialStareServiceImpl.java

@@ -269,17 +269,22 @@ public class MaterialStareServiceImpl implements MaterialStareService {
 
             //当天总消耗
             JSONObject jsonObjectNow = materialStareMapper.getKuaiShouTotalCost(nowDate,nowDate,nowHour,userSet);
-            resultMap.put("todayCost",jsonObjectNow.getString("totalCost"));
+            resultMap.put("todayCost",Check.isNull(jsonObjectNow.getString("totalCost")) ? "0" : jsonObjectNow.getString("totalCost"));
             //昨天同时段总消耗
             JSONObject jsonObjectYesterday = materialStareMapper.getKuaiShouTotalCost(time,time,nowHour,userSet);
 
             //今日同比 = (今天总消耗 - 昨天总消耗 ) / 昨天总消耗
-            Double d = (Double.valueOf(jsonObjectNow.getString("totalCost")) - Double.valueOf(jsonObjectYesterday.getString("totalCost"))) / Double.valueOf(jsonObjectYesterday.getString("totalCost"));
+            Double d = new Double("0");
+            if (!Check.isNull( jsonObjectNow.getString("totalCost")) && !Check.isNull(jsonObjectYesterday.getString("totalCost"))){
+                 d = (Double.valueOf(jsonObjectNow.getString("totalCost"))
+                        - Double.valueOf(jsonObjectYesterday.getString("totalCost")))
+                        / Double.valueOf(jsonObjectYesterday.getString("totalCost"));
+            }
             resultMap.put("todayCompare",decimalFormat.format(d));
 
             //所选时段消耗
             JSONObject timeNowCost = materialStareMapper.getKuaiShouTotalCostDaily(stratDate,endDate,userSet);
-            resultMap.put("timeCost",timeNowCost.getString("totalCost"));
+            resultMap.put("timeCost",Check.isNull(timeNowCost.getString("totalCost")) ? "0" : timeNowCost.getString("totalCost"));
             //上阶段时间
             Map<String,String> lastTime = DateUtils.getStartEndTime(startTime,endTime);
             long lastTimeStart = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeStart")));
@@ -288,7 +293,11 @@ public class MaterialStareServiceImpl implements MaterialStareService {
             //上阶段消耗
             JSONObject timeLastCost = materialStareMapper.getKuaiShouTotalCostDaily(lastTimeStart,lastTimeEnd,userSet);
             //环比 = (当前总消耗 - 上阶段总消耗 ) / 上阶段总消耗
-            Double timeCompare = (Double.valueOf(timeNowCost.getString("totalCost")) - Double.valueOf(timeLastCost.getString("totalCost"))) / Double.valueOf(timeLastCost.getString("totalCost"));
+            Double timeCompare = new Double("0");
+            if (!Check.isNull(timeNowCost.getString("totalCost")) && !Check.isNull(timeLastCost.getString("totalCost"))){
+                timeCompare = (Double.valueOf(timeNowCost.getString("totalCost")) - Double.valueOf(timeLastCost.getString("totalCost"))) / Double.valueOf(timeLastCost.getString("totalCost"));
+            }
+
             resultMap.put("timeCompare",decimalFormat.format(timeCompare));
 
             //当前月份的框返 和 激励
@@ -296,13 +305,19 @@ public class MaterialStareServiceImpl implements MaterialStareService {
             long monthFirstDay = Long.valueOf(DateUtils.getFirstDayByMonth());
             //框返 激励
             JSONObject nowMonthCost = materialStareMapper.getKuaiShouAccountCharged(monthFirstDay,nowDate,userSet);
-            resultMap.put("directCharged",nowMonthCost.getString("directCharged"));//框返
-            resultMap.put("contractCharged",nowMonthCost.getString("contractCharged"));//激励
+
+
+
+            resultMap.put("directCharged",Check.isNull(nowMonthCost) ? "0" : nowMonthCost.getString("directCharged"));//框返
+            resultMap.put("contractCharged",Check.isNull(nowMonthCost) ? "0" : nowMonthCost.getString("contractCharged"));//激励
 
             //当前月消耗
             JSONObject monthCost = materialStareMapper.getKuaiShouAccountCostMonth(userId, monthFirstDay,nowDate);
             resultMap.put("monthCost",Check.isNull(monthCost) ? "0" : monthCost.getString("cost"));
-            resultMap.put("userName",Check.isNull(monthCost) ? "-" : monthCost.getString("userName"));
+
+            //用户
+            JSONObject userName = materialStareMapper.getKuaiShouUserByUserId(userId);
+            resultMap.put("userName",Check.isNull(userName) ? "-" : userName.getString("userName"));
 
 
             //公司 组内排名