Browse Source

修改sql查询逻辑bug

songyh 4 years ago
parent
commit
8b3f6b6827
14 changed files with 100 additions and 73 deletions
  1. 9 9
      jeecg-boot-report/src/main/java/cn/com/ctop/common/constant/AccountReportConstants.java
  2. 9 4
      jeecg-boot-report/src/main/java/cn/com/ctop/report/controller/KuaishouAccountReportDailyDwController.java
  3. 4 4
      jeecg-boot-report/src/main/java/cn/com/ctop/report/controller/KuaishouMaterialReportDailyDwController.java
  4. 4 1
      jeecg-boot-report/src/main/java/cn/com/ctop/report/entity/AccountAttributionInfo.java
  5. 6 6
      jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/AccountAttributionInfoMapper.java
  6. 1 1
      jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/KuaishouAccountReportDailyDwMapper.java
  7. 1 1
      jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/KuaishouAccountReportHourlyDwMapper.java
  8. 1 1
      jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/KuaishouMaterialVideoReportDailyDwMapper.java
  9. 10 8
      jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/xml/AccountAttributionInfoMapper.xml
  10. 3 3
      jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/xml/KuaishouAccountReportDailyDwMapper.xml
  11. 13 12
      jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/xml/KuaishouMaterialVideoReportDailyDwMapper.xml
  12. 21 11
      jeecg-boot-report/src/main/java/cn/com/ctop/report/service/impl/AccountAttributionInfoServiceImpl.java
  13. 15 9
      jeecg-boot-report/src/main/java/cn/com/ctop/report/service/impl/KuaishouAccountReportDailyDwServiceImpl.java
  14. 3 3
      jeecg-boot-report/src/main/resources/application-dev.yml

+ 9 - 9
jeecg-boot-report/src/main/java/cn/com/ctop/common/constant/AccountReportConstants.java

@@ -16,11 +16,11 @@ public class AccountReportConstants {
             "    \"comment\": \"消耗\"\n" +
             "  },\n" +
             "  \"showMaterial\": {\n" +
-            "    \"filed\": \"IFNULL(sum(t1.show_num),0) as showMaterial \",\n" +
+            "    \"filed\": \"IFNULL(sum(t1.`show`),0) as showMaterial \",\n" +
             "    \"comment\": \"展示数\"\n" +
             "  },\n" +
             "  \"cpm\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(t1.cost) / sum(t1.show_num) IS NULL THEN 0 ELSE ROUND((sum(t1.cost) / sum(t1.show_num)) * 1000, 2 ) END AS cpm \",\n" +
+            "    \"filed\": \"CASE WHEN sum(t1.cost) / sum(t1.`show`) IS NULL THEN 0 ELSE ROUND((sum(t1.cost) / sum(t1.`show`)) * 1000, 2 ) END AS cpm \",\n" +
             "    \"comment\": \"平均千次展现费用\"\n" +
             "  },\n" +
             "  \"clickMaterial\": {\n" +
@@ -28,7 +28,7 @@ public class AccountReportConstants {
             "    \"comment\": \"点击数\"\n" +
             "  },\n" +
             "  \"ctr\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(t1.show_num) != 0 THEN concat(CAST(round( sum(t1.click) /sum(t1.show_num)*100,2) AS CHAR),'%') ELSE '0%' end as ctr \",\n" +
+            "    \"filed\": \"CASE WHEN sum(t1.`show`) != 0 THEN concat(CAST(round( sum(t1.click) /sum(t1.`show`)*100,2) AS CHAR),'%') ELSE '0%' end as ctr \",\n" +
             "    \"comment\": \"点击率\"\n" +
             "  },\n" +
             "  \"cpc\": {\n" +
@@ -158,7 +158,7 @@ public class AccountReportConstants {
             "    \"comment\": \"消耗\"\n" +
             "  },\n" +
             "  \"photoShow\": {\n" +
-            "    \"filed\": \"IFNULL(sum(show),0) as photoShow \",\n" +
+            "    \"filed\": \"IFNULL(sum(`show`),0) as photoShow \",\n" +
             "    \"comment\": \"封面曝光数\"\n" +
             "  },\n" +
             "  \"photoClick\": {\n" +
@@ -174,7 +174,7 @@ public class AccountReportConstants {
             "    \"comment\": \"行为数\"\n" +
             "  },\n" +
             "  \"clickRate\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(show) != 0  THEN ROUND(sum(photo_click)/sum(show)*100,2)  else 0 END AS clickRate \",\n" +
+            "    \"filed\": \"CASE WHEN sum(`show`) != 0  THEN ROUND(sum(photo_click)/sum(`show`)*100,2)  else 0 END AS clickRate \",\n" +
             "    \"comment\": \"封面点击率\"\n" +
             "  },\n" +
             "  \"bClickRate\": {\n" +
@@ -182,7 +182,7 @@ public class AccountReportConstants {
             "    \"comment\": \"行为率\"\n" +
             "  },\n" +
             "  \"cpm\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(charge)/sum(show) IS NULL THEN 0 ELSE ROUND(sum(charge)/sum(show)*1000, 3 ) END AS cpm \",\n" +
+            "    \"filed\": \"CASE WHEN sum(charge)/sum(`show`) IS NULL THEN 0 ELSE ROUND(sum(charge)/sum(`show`)*1000, 3 ) END AS cpm \",\n" +
             "    \"comment\": \"平均千次封面曝光花费\"\n" +
             "  },\n" +
             "  \"cpc\": {\n" +
@@ -368,7 +368,7 @@ public class AccountReportConstants {
             "    \"comment\": \"消耗\"\n" +
             "  },\n" +
             "  \"photoShow\": {\n" +
-            "    \"filed\": \"IFNULL(sum(show),0) as photoShow \",\n" +
+            "    \"filed\": \"IFNULL(sum(`show`),0) as photoShow \",\n" +
             "    \"comment\": \"封面曝光数\"\n" +
             "  },\n" +
             "  \"photoClick\": {\n" +
@@ -384,7 +384,7 @@ public class AccountReportConstants {
             "    \"comment\": \"行为数\"\n" +
             "  },\n" +
             "  \"clickRate\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(show) != 0    THEN ROUND(sum(photo_click) / sum(show) * 100,2) else 0 END AS clickRate \",\n" +
+            "    \"filed\": \"CASE WHEN sum(`show`) != 0    THEN ROUND(sum(photo_click) / sum(`show`) * 100,2) else 0 END AS clickRate \",\n" +
             "    \"comment\": \"封面点击率\"\n" +
             "  },\n" +
             "  \"bClickRate\": {\n" +
@@ -392,7 +392,7 @@ public class AccountReportConstants {
             "    \"comment\": \"行为率\"\n" +
             "  },\n" +
             "  \"cpm\": {\n" +
-            "    \"filed\": \"CASE WHEN sum(charge)/sum(show) IS NULL THEN 0 ELSE ROUND(sum(charge)/sum(show)*1000,3) END AS cpm \",\n" +
+            "    \"filed\": \"CASE WHEN sum(charge)/sum(`show`) IS NULL THEN 0 ELSE ROUND(sum(charge)/sum(`show`)*1000,3) END AS cpm \",\n" +
             "    \"comment\": \"平均千次封面曝光花费\"\n" +
             "  },\n" +
             "  \"cpc\": {\n" +

+ 9 - 4
jeecg-boot-report/src/main/java/cn/com/ctop/report/controller/KuaishouAccountReportDailyDwController.java

@@ -9,6 +9,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -16,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.math.BigDecimal;
+import java.text.ParseException;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -49,13 +51,13 @@ public class KuaishouAccountReportDailyDwController {
      * 查询账户报表数据
      */
     @PostMapping("/kuaishou/list")
-    public Result<List<JSONObject>> getListReport(@RequestBody JSONObject requestBody) {
+    public Result<List<JSONObject>> getListReport(@RequestBody JSONObject requestBody) throws ParseException {
         Result<List<JSONObject>> result = new Result<>();
         if (requestBody.isEmpty()) {
             log.error("request body is empty");
             result.setSuccess(false);
         }
-        BigDecimal discount = requestBody.getBigDecimal("discount");
+        BigDecimal discount = requestBody.getBigDecimal("disscount");
         JSONArray accounts = requestBody.getJSONArray("accountIds");
         String userId = requestBody.getString("userId");
         if (accounts.isEmpty()) {
@@ -67,7 +69,10 @@ public class KuaishouAccountReportDailyDwController {
         }
         String startDate = requestBody.getString("startDate");
         String endDate = requestBody.getString("endDate");
-        int hour = requestBody.getInteger("hour");
+        Integer hour = requestBody.getInteger("hour");
+        if(null == hour){
+            hour = DateUtils.getNowHour();
+        }
         String target = requestBody.getString("target");
         String order = requestBody.getString("order");
         try {
@@ -93,7 +98,7 @@ public class KuaishouAccountReportDailyDwController {
             resultBody.setSuccess(false);
         }
         String mediaId = requestBody.getString("mediaId");
-        BigDecimal discount = requestBody.getBigDecimal("discount");
+        BigDecimal discount = requestBody.getBigDecimal("disscount");
         JSONArray accounts = requestBody.getJSONArray("accountIds");
         if (accounts.isEmpty()) {
             return resultBody;

+ 4 - 4
jeecg-boot-report/src/main/java/cn/com/ctop/report/controller/KuaishouMaterialReportDailyDwController.java

@@ -115,8 +115,8 @@ public class KuaishouMaterialReportDailyDwController {
             }
             Map<String, Object> requestMap = new HashMap<>();
             requestMap.put("filed", filedAll);
-            requestMap.put("startDate", startDate);
-            requestMap.put("endDate", endDate);
+            requestMap.put("startDate", Long.parseLong(startDate.replace("-","")));
+            requestMap.put("endDate", Long.parseLong(endDate.replace("-","")));
 
             if (!Check.isNull(requestBody.getJSONArray("accountIds"))) {
                 requestMap.put("accountIds", requestBody.getJSONArray("accountIds"));
@@ -128,8 +128,8 @@ public class KuaishouMaterialReportDailyDwController {
             if (!Check.isNull(requestBody.getString("order"))) {
                 requestMap.put("order", requestBody.getString("order"));
             }
-            if (!Check.isNull(requestBody.getString("channelType"))) {
-                requestMap.put("channelType", requestBody.getString("channelType"));
+            if (!Check.isNull(requestBody.getInteger("channelType"))) {
+                requestMap.put("channelType", requestBody.getInteger("channelType"));
             }
             String roleCode = sysRoleMapper.getRoleCodeByUserId(userId);
             if ("admin".equals(roleCode)) {

+ 4 - 1
jeecg-boot-report/src/main/java/cn/com/ctop/report/entity/AccountAttributionInfo.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.report.entity;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
@@ -19,12 +20,14 @@ public class AccountAttributionInfo {
     private Long productId;
     private String advertiserId;
     private String companyId;
-    private String authName;
     private String projectName;
     private String advertiserName;
     private String companyName;
     private String saleId;
     private String userId;
     private String orgCode;
+    @TableField(exist = false)
     private String userName;
+    @TableField(exist = false)
+    private String authName;
 }

+ 6 - 6
jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/AccountAttributionInfoMapper.java

@@ -16,20 +16,20 @@ public interface AccountAttributionInfoMapper extends BaseMapper<AccountAttribut
     List<AccountAttributionInfo> selectDesignAccuntsByParams(@Param(value = "mediaList")List<Integer> mediaList, @Param(value = "designUserId")String designUserId);
 
     //今日汇总数据
-    JSONObject queryTodaySumReportBy(@Param("statDate") String statDate, @Param("accountIds") JSONArray accountIds);
+    JSONObject queryTodaySumReportBy(@Param("statDate") Long statDate, @Param("accountIds") JSONArray accountIds);
 
     //根据小时区间查询今日汇总数据
-    JSONObject queryTodaySumByHour(@Param("statDate") String statDate, @Param("hour") int hour, @Param("accountIds") JSONArray accountIds);
+    JSONObject queryTodaySumByHour(@Param("statDate") Long statDate, @Param("hour") int hour, @Param("accountIds") JSONArray accountIds);
 
     //根据开始、结束时间 查询汇总数据
-    JSONObject querySumByStartEndDate(@Param("endDate") String endDate, @Param("startDate") String startDate, @Param("accountIds") JSONArray accountIds);
+    JSONObject querySumByStartEndDate(@Param("endDate") Long endDate, @Param("startDate") Long startDate, @Param("accountIds") JSONArray accountIds);
 
     //今日明细数据
-    List<JSONObject> queryTodayDetailReportBy(@Param("filed") String filed, @Param("statDate") String statDate, @Param("accountIds") JSONArray accountIds);
+    List<JSONObject> queryTodayDetailReportBy(@Param("filed") String filed, @Param("statDate") Long statDate, @Param("accountIds") JSONArray accountIds);
 
     //按月分组查询明细数据
-    List<JSONObject> queryDetailGroupMonthByDate(@Param("endDate") String endDate, @Param("startDate") String startDate, @Param("accountIds") JSONArray accountIds);
+    List<JSONObject> queryDetailGroupMonthByDate(@Param("endDate") Long endDate, @Param("startDate") Long startDate, @Param("accountIds") JSONArray accountIds);
 
     //根据开始、结束时间 查询明细数据
-    List<JSONObject> queryDetailByStartEndDate(@Param("endDate") String endDate, @Param("startDate") String startDate, @Param("accountIds") JSONArray accountIds);
+    List<JSONObject> queryDetailByStartEndDate(@Param("endDate") Long endDate, @Param("startDate") Long startDate, @Param("accountIds") JSONArray accountIds);
 }

+ 1 - 1
jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/KuaishouAccountReportDailyDwMapper.java

@@ -9,5 +9,5 @@ import org.apache.ibatis.annotations.Param;
 import java.util.List;
 
 public interface KuaishouAccountReportDailyDwMapper extends BaseMapper<KuaishouAccountReportDailyDw> {
-    List<JSONObject> getReportByParams(@Param(value = "filedAll") String filedAll, @Param(value = "endDate")String endDate, @Param(value = "startDate")String startDate, @Param(value = "accounts")JSONArray accounts, @Param(value = "target")String target, @Param(value = "order")String order, @Param(value = "hasGroupBy")int hasGroupBy,@Param(value = "groupBy")String groupBy);
+    List<JSONObject> getReportByParams(@Param(value = "filedAll") String filedAll, @Param(value = "endDate")Long endDate, @Param(value = "startDate")Long startDate, @Param(value = "accountIds")JSONArray accounts, @Param(value = "target")String target, @Param(value = "order")String order, @Param(value = "hasGroupBy")int hasGroupBy,@Param(value = "groupBy")String groupBy);
 }

+ 1 - 1
jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/KuaishouAccountReportHourlyDwMapper.java

@@ -9,5 +9,5 @@ import org.apache.ibatis.annotations.Param;
 import java.util.List;
 
 public interface KuaishouAccountReportHourlyDwMapper extends BaseMapper<KuaishouAccountReportHourlyDw> {
-    List<JSONObject> getReportByParams(@Param(value = "filedAll") String filedAll, @Param(value = "startDate")String startDate, @Param(value = "hour")int hour, @Param(value = "accounts")JSONArray accounts, @Param(value = "target")String target, @Param(value = "order")String order, @Param(value = "hasGroupBy")int hasGroupBy,@Param(value = "groupBy")String groupBy);
+    List<JSONObject> getReportByParams(@Param(value = "filedAll") String filedAll, @Param(value = "startDate")Long startDate, @Param(value = "hour")int hour, @Param(value = "accounts")JSONArray accounts, @Param(value = "target")String target, @Param(value = "order")String order, @Param(value = "hasGroupBy")int hasGroupBy,@Param(value = "groupBy")String groupBy);
 }

+ 1 - 1
jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/KuaishouMaterialVideoReportDailyDwMapper.java

@@ -12,7 +12,7 @@ import java.util.Map;
 public interface KuaishouMaterialVideoReportDailyDwMapper extends BaseMapper<KuaishouMaterialVideoReportDailyDw> {
     Long getTotalByMap(Map<String, Object> requestMap);
 
-    List getKuaiShouVideoReportByMap(Map<String, Object> requestMap);
+    List<JSONObject> getKuaiShouVideoReportByMap(Map<String, Object> requestMap);
 
     List<JSONObject> queryVideoDetailBy(@Param("accountIds") JSONArray accountIds, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("filed") String filed, @Param("signature") String signature);
 }

+ 10 - 8
jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/xml/AccountAttributionInfoMapper.xml

@@ -28,8 +28,10 @@
     </insert>
     <select id="selectByParams" resultType="cn.com.ctop.report.entity.AccountAttributionInfo">
         select
-               caai.*
-        from jeecg-boot.ctop_user_allocation cua
+               caai.*,
+               cua.auth_name,
+               cua.user_name
+        from `jeecg-boot`.ctop_user_allocation cua
         left join `jeecg-boot`.ctop_account_attribution_info caai on caai.account_id = cua.account_id
         where cua.media_id in
         <foreach collection="mediaList" item="item" separator=","
@@ -72,7 +74,7 @@
         <select id="queryTodaySumReportBy" resultType="com.alibaba.fastjson.JSONObject">
             SELECT
             ROUND(sum(charge),3) cost,
-            sum(photo_show) photoShow,
+            sum('show') photoShow,
             sum(photo_click) photoClick,
             sum(aClick) as aClick,
             max(stat_hour) maxHour
@@ -90,7 +92,7 @@
         <select id="queryTodaySumByHour" resultType="com.alibaba.fastjson.JSONObject">
             SELECT
             ROUND(sum(charge),2) cost,
-            sum(photo_show) photoShow,
+            sum(`show`) photoShow,
             sum(photo_click) photoClick,
             sum(aClick) as aClick
             FROM
@@ -109,7 +111,7 @@
         <select id="queryTodayDetailReportBy" resultType="com.alibaba.fastjson.JSONObject">
             SELECT
             ROUND(sum(charge),3) cost,
-            sum(photo_show) photoShow,
+            sum(`show`) photoShow,
             sum(photo_click) photoClick,
             sum(aClick) as aClick,
             stat_hour as statHour
@@ -132,7 +134,7 @@
         <select id="querySumByStartEndDate" resultType="com.alibaba.fastjson.JSONObject">
             SELECT
             ROUND(sum(charge),3) cost,
-            sum(photo_show) photoShow,
+            sum(`show`) photoShow,
             sum(photo_click) photoClick,
             sum(aClick) as aClick
             FROM kuaishou_account_report_daily_dw t1
@@ -150,7 +152,7 @@
         <select id="queryDetailByStartEndDate" resultType="com.alibaba.fastjson.JSONObject">
             SELECT
             ROUND(sum(charge),3) cost,
-            sum(photo_show) photoShow,
+            sum(`show`) photoShow,
             sum(photo_click) photoClick,
             sum(aClick) as aClick,
             stat_date as statDate
@@ -170,7 +172,7 @@
         <select id="queryDetailGroupMonthByDate" resultType="com.alibaba.fastjson.JSONObject">
             SELECT
             ROUND(sum(charge),3) cost,
-            sum(photo_show) photoShow,
+            sum(`show`) photoShow,
             sum(photo_click) photoClick,
             sum(aClick) as aClick,
             DATE_FORMAT(t1.stat_date, '%Y-%m') statDate

+ 3 - 3
jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/xml/KuaishouAccountReportDailyDwMapper.xml

@@ -6,10 +6,10 @@
         SELECT
         stat_date as statDate,
         account_id as accountId,
-        auth_name as authName,
-        ${filed}
+        account_name as authName,
+        ${filedAll}
         FROM
-        ctop_kuaishou_report_daily_account
+        kuaishou_account_report_daily_dw
         WHERE
         stat_date &lt;= #{endDate}
         AND stat_date &gt;= #{startDate}

+ 13 - 12
jeecg-boot-report/src/main/java/cn/com/ctop/report/mapper/xml/KuaishouMaterialVideoReportDailyDwMapper.xml

@@ -44,20 +44,21 @@
         GROUP BY t1.signature
         ) t2
     </select>
-    <select id="getKuaiShouVideoReportByMap" resultType="java.util.List">
+    <select id="getKuaiShouVideoReportByMap" resultType="com.alibaba.fastjson.JSONObject" parameterType="map">
         SELECT
-        t1.*,
-        IFNULL(t1.clip_name,'-') as clip,
-        IFNULL(t1.plan_name,'-') as plan,
-        IFNULL(t1.shot_name,'-') as shot,
-        IFNULL(t1.design_team_leader_name,'-') as designLeader,
-        IFNULL(t1.video_name,'-') as materialName,
-        IFNULL(t1.cover_url,'-') as coverUrl,
-        IFNULL(t1.url,'-') as url ,
-        IFNULL(t1.channel_name,'-') AS channel,
-        IFNULL(t1.state_date,'-') as createTime
+        t1.*
         FROM
-        (select ${filed}
+        (select
+        IFNULL( clip_name, '-' ) AS clip,
+        IFNULL( plan_name, '-' ) AS plan,
+        IFNULL( shot_name, '-' ) AS shot,
+        IFNULL( leader_name, '-' ) AS designLeader,
+        IFNULL( video_name, '-' ) AS materialName,
+        IFNULL( cover_url, '-' ) AS coverUrl,
+        IFNULL( photo_url, '-' ) AS url,
+        IFNULL( channel_type, '-' ) AS channel,
+        IFNULL( stat_date, '-' ) AS createTime,
+                ${filed}
         from kuaishou_material_video_report_daily_dw
         where 1 = 1
         <if test="accountIds !=null and accountIds != ''">

+ 21 - 11
jeecg-boot-report/src/main/java/cn/com/ctop/report/service/impl/AccountAttributionInfoServiceImpl.java

@@ -94,7 +94,7 @@ public class AccountAttributionInfoServiceImpl extends ServiceImpl<AccountAttrib
         List<AccountAttributionInfo>accountAttributionInfos = getAccountInfoList(userId,mediaType);
         Map<Long,Long> projectIdMaps = new HashMap<>();
         for(AccountAttributionInfo attributionInfo:accountAttributionInfos){
-            if(null!=attributionInfo.getProjectId()&&attributionInfo.getProjectId()!=0){
+            if(null!=attributionInfo&&null!=attributionInfo.getProjectId()&&attributionInfo.getProjectId()!=0){
                 projectIdMaps.putIfAbsent(attributionInfo.getProjectId(),attributionInfo.getProjectId());
             }
         }
@@ -120,7 +120,7 @@ public class AccountAttributionInfoServiceImpl extends ServiceImpl<AccountAttrib
     private List<AccountAttributionInfo> getAccountInfoListByProjectId(Long projectId, List<AccountAttributionInfo> accountAttributionInfos) {
         List<AccountAttributionInfo>result = new ArrayList<>();
         for(AccountAttributionInfo attributionInfo:accountAttributionInfos){
-            if(null!=attributionInfo.getProjectId()&&attributionInfo.getProjectId().equals(projectId)){
+            if(null!=attributionInfo&&null!=attributionInfo.getProjectId()&&attributionInfo.getProjectId().equals(projectId)){
                 result.add(attributionInfo);
             }
         }
@@ -204,17 +204,22 @@ public class AccountAttributionInfoServiceImpl extends ServiceImpl<AccountAttrib
         Map<String, Object> result = new HashMap<>();
         JSONObject after;
         JSONObject before;
-        if (startDate.equals(endDate)) {
-            after = accountAttributionInfoMapper.queryTodaySumReportBy(startDate, accounts);
+        Long startDateNum = Long.parseLong(startDate.replace("-",""));
+        Long anotherStartDateNum = Long.parseLong(DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, startDate, -1).replace("-",""));
+
+        Long endDateNum = Long.parseLong(endDate.replace("-",""));
+        Long anotherEndDateNum = Long.parseLong(DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, endDate, -1).replace("-",""));
+        if (startDateNum.equals(endDateNum)) {
+            after = accountAttributionInfoMapper.queryTodaySumReportBy(startDateNum, accounts);
             if (after == null) {
                 return result;
             }
-            before = accountAttributionInfoMapper.queryTodaySumByHour(DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, startDate, -1), after.getInteger("maxHour"), accounts);
+            before = accountAttributionInfoMapper.queryTodaySumByHour(anotherStartDateNum, after.getInteger("maxHour"), accounts);
             if (before == null) {
                 before = after;
             }
         } else {
-            after = accountAttributionInfoMapper.querySumByStartEndDate(endDate, startDate, accounts);
+            after = accountAttributionInfoMapper.querySumByStartEndDate(endDateNum, startDateNum, accounts);
             if (after == null) {
                 return result;
             }
@@ -228,9 +233,14 @@ public class AccountAttributionInfoServiceImpl extends ServiceImpl<AccountAttrib
     public List<JSONObject> getChartDataBy(String mediaId, BigDecimal discount, JSONArray accounts, String startDate, String endDate) throws ParseException {
         List<JSONObject> result = new ArrayList<>();
         String filedAll = JsonResourceUtil.joinAllFiled(AccountReportConstants.getDicMapKs());
-        if (startDate.equals(endDate)) {
-            List<JSONObject> after = accountAttributionInfoMapper.queryTodayDetailReportBy(filedAll, startDate, accounts);
-            List<JSONObject> before = accountAttributionInfoMapper.queryTodayDetailReportBy(filedAll, DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, startDate, -1), accounts);
+        Long startDateNum = Long.parseLong(startDate.replace("-",""));
+        Long anotherStartDateNum = Long.parseLong(DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, startDate, -1).replace("-",""));
+
+        Long endDateNum = Long.parseLong(endDate.replace("-",""));
+        Long anotherEndDateNum = Long.parseLong(DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, endDate, -1).replace("-",""));
+        if (startDateNum.equals(endDateNum)) {
+            List<JSONObject> after = accountAttributionInfoMapper.queryTodayDetailReportBy(filedAll, startDateNum, accounts);
+            List<JSONObject> before = accountAttributionInfoMapper.queryTodayDetailReportBy(filedAll, anotherStartDateNum, accounts);
             if (after.size() == 0) {
                 return result;
             }
@@ -244,9 +254,9 @@ public class AccountAttributionInfoServiceImpl extends ServiceImpl<AccountAttrib
             List<JSONObject> after;
             //判断是不是日期间隔大于半年
             if (DateUtils.isMoreSixMonth(startDate, endDate)) {
-                after = accountAttributionInfoMapper.queryDetailGroupMonthByDate(endDate, startDate, accounts);
+                after = accountAttributionInfoMapper.queryDetailGroupMonthByDate(endDateNum, startDateNum, accounts);
             } else {
-                after = accountAttributionInfoMapper.queryDetailByStartEndDate(endDate, startDate, accounts);
+                after = accountAttributionInfoMapper.queryDetailByStartEndDate(endDateNum, startDateNum, accounts);
             }
             if (after == null) {
                 return result;

+ 15 - 9
jeecg-boot-report/src/main/java/cn/com/ctop/report/service/impl/KuaishouAccountReportDailyDwServiceImpl.java

@@ -31,19 +31,25 @@ public class KuaishouAccountReportDailyDwServiceImpl extends ServiceImpl<Kuaisho
     public List<JSONObject> getListDataByParams(String mediaId, BigDecimal discount, JSONArray accounts, String startDate, String endDate, int hour, String target, String order) {
         List<JSONObject> result;
         String filedAll = JsonResourceUtil.joinAllFiled(AccountReportConstants.getDicMapKs());
-        if (startDate.equals(endDate)) {
+        Long startDateNum = Long.parseLong(startDate.replace("-",""));
+        Long anotherStartDateNum = Long.parseLong(DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, startDate, -1).replace("-",""));
+
+        Long endDateNum = Long.parseLong(endDate.replace("-",""));
+        Long anotherEndDateNum = Long.parseLong(DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, endDate, -1).replace("-",""));
+
+        if (startDateNum.equals(endDateNum)) {
             String groupBy = "account_id";
             if (startDate.equals(DateUtils.date2Str())) {
-                result = kuaishouAccountReportHourlyDwMapper.getReportByParams(filedAll, startDate, hour, accounts, target, order,1,groupBy);
-                JSONObject afterSum = kuaishouAccountReportHourlyDwMapper.getReportByParams(filedAll, startDate, hour, accounts,target,order,0,groupBy).get(0);
-                JSONObject beforeSum = kuaishouAccountReportHourlyDwMapper.getReportByParams(filedAll, DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, startDate, -1), hour, accounts,target,order,0,groupBy).get(0);
+                result = kuaishouAccountReportHourlyDwMapper.getReportByParams(filedAll, startDateNum, hour, accounts, target, order,1,groupBy);
+                JSONObject afterSum = kuaishouAccountReportHourlyDwMapper.getReportByParams(filedAll, startDateNum, hour, accounts,target,order,0,groupBy).get(0);
+                JSONObject beforeSum = kuaishouAccountReportHourlyDwMapper.getReportByParams(filedAll,anotherStartDateNum , hour, accounts,target,order,0,groupBy).get(0);
                 result.add(afterSum);
                 result.add(beforeSum);
                 result.add(countTotal(afterSum, beforeSum));
             } else {
-                result = kuaishouAccountReportDailyDwMapper.getReportByParams(filedAll, endDate, startDate, accounts, target, order,1,groupBy);
-                JSONObject afterSum = kuaishouAccountReportDailyDwMapper.getReportByParams(filedAll, endDate, startDate, accounts,target,order,0,groupBy).get(0);
-                JSONObject beforeSum = kuaishouAccountReportDailyDwMapper.getReportByParams(filedAll, DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, endDate, -1), DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, startDate, -1), accounts,target,order,0,groupBy).get(0);
+                result = kuaishouAccountReportDailyDwMapper.getReportByParams(filedAll, endDateNum, startDateNum, accounts, target, order,1,groupBy);
+                JSONObject afterSum = kuaishouAccountReportDailyDwMapper.getReportByParams(filedAll, endDateNum, startDateNum, accounts,target,order,0,groupBy).get(0);
+                JSONObject beforeSum = kuaishouAccountReportDailyDwMapper.getReportByParams(filedAll, anotherEndDateNum, anotherStartDateNum, accounts,target,order,0,groupBy).get(0);
                 result.add(afterSum);
                 result.add(beforeSum);
                 result.add(countTotal(afterSum, beforeSum));
@@ -53,8 +59,8 @@ public class KuaishouAccountReportDailyDwServiceImpl extends ServiceImpl<Kuaisho
             if (accounts.size() > 1) {
                 groupBy = "account_id";
             }
-            result = kuaishouAccountReportDailyDwMapper.getReportByParams(filedAll, endDate, startDate, accounts, target, order,1,groupBy);
-            List<JSONObject> totalList = kuaishouAccountReportDailyDwMapper.getReportByParams(filedAll, endDate, startDate, accounts,target,order,0,groupBy);
+            result = kuaishouAccountReportDailyDwMapper.getReportByParams(filedAll, endDateNum, startDateNum, accounts, target, order,1,groupBy);
+            List<JSONObject> totalList = kuaishouAccountReportDailyDwMapper.getReportByParams(filedAll, endDateNum, startDateNum, accounts,target,order,0,groupBy);
             if(null!=totalList&&!totalList.isEmpty()){
                 result.add(totalList.get(0));
             }

+ 3 - 3
jeecg-boot-report/src/main/resources/application-dev.yml

@@ -105,9 +105,9 @@ spring:
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
       datasource:
         master:
-          url: jdbc:mysql://192.168.1.187:4000/application?characterEncoding=UTF-8&useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
-          username: root
-          password: hcst2021
+          url: jdbc:mysql://139.186.27.96:3390/application?characterEncoding=UTF-8&useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
+          username: data
+          password: hcst@2021
           driver-class-name: com.mysql.jdbc.Driver
   #redis 配置
   redis: