ソースを参照

营销首页统计开发

anderx 2 年 前
コミット
f5b6de6a27

+ 39 - 21
src/main/java/com/goafanti/admin/service/impl/AdminStatisticsServiceImpl.java

@@ -54,30 +54,49 @@ public class AdminStatisticsServiceImpl implements AdminStatisticsService {
         //获取当月的列表
         Map<String,Object> map=new HashMap<>();
         Days days = new Days();
-        List thisMonth = getThisMonth(days);
+        List<String> thisMonth = getThisMonth(days);
         List<AdminUserCount> userList = adminMapper.thisMonthUser(days.firstDay,days.endDay, aid);
         List<Integer> signList=new ArrayList<>();
         List<Integer> privateList=new ArrayList<>();
         List<Integer> channelList=new ArrayList<>();
         List<Integer> userFollowList=new ArrayList<>();
         List<Integer> orderList=new ArrayList<>();
-            int signCount=0,privateCount=0,channelCount=0,followCount=0,orderCount=0;
-        for (AdminUserCount e : userList) {
-            signCount=signCount+e.getSignCount();
-            int newSign=signCount;
-            signList.add(newSign);
-            privateCount=privateCount+e.getPrivateCount();
-            int newPrivate=privateCount;
-            privateList.add(newPrivate);
-            channelCount=channelCount+e.getChannelCount();
-            int newChannel=channelCount;
-            channelList.add(newChannel);
-            followCount=followCount+e.getFollowCount();
-            int newFollow=followCount;
-            channelList.add(newFollow);
-            orderCount=orderCount+e.getOrderCount();
-            int newOrder=orderCount;
-            channelList.add(newOrder);
+        List<Integer> publicReleaseList=new ArrayList<>();
+            int signCount=0,privateCount=0,channelCount=0,followCount=0,orderCount=0,publicReleaseCount=0;
+        for (String dates : thisMonth) {
+            boolean flag=true;
+            for (AdminUserCount e : userList) {
+                String formatDate = DateUtils.formatDate(e.getDateTime(), AFTConstants.YYYYMMDD);
+                if (dates.equals(formatDate)){
+                    signCount=signCount+e.getSignCount();
+                    int newSign=signCount;
+                    signList.add(newSign);
+                    privateCount=privateCount+e.getPrivateCount();
+                    int newPrivate=privateCount;
+                    privateList.add(newPrivate);
+                    channelCount=channelCount+e.getChannelCount();
+                    int newChannel=channelCount;
+                    channelList.add(newChannel);
+                    followCount=followCount+e.getFollowCount();
+                    int newFollow=followCount;
+                    userFollowList.add(newFollow);
+                    orderCount=orderCount+e.getOrderCount();
+                    int newOrder=orderCount;
+                    orderList.add(newOrder);
+                    publicReleaseCount=publicReleaseCount+e.getPublicReleaseCount();
+                    int newPublicRelease=publicReleaseCount;
+                    publicReleaseList.add(newPublicRelease);
+                    flag=false;
+                }
+            }
+            if (flag){
+                signList.add(signCount);
+                privateList.add(privateCount);
+                channelList.add(channelCount);
+                userFollowList.add(followCount);
+                orderList.add(orderCount);
+                publicReleaseList.add(publicReleaseCount);
+            }
         }
         map.put("dates",thisMonth);
         map.put("signList",signList);
@@ -88,9 +107,7 @@ public class AdminStatisticsServiceImpl implements AdminStatisticsService {
         //订单数
         map.put("orderList",orderList);
         //公出企业数
-        List<Integer> publicReleaseList = adminMapper.thisMonthPublicRelease(thisMonth,days.firstDay,  aid);
         map.put("publicReleaseList",publicReleaseList);
-
         return map;
     }
 
@@ -101,7 +118,7 @@ public class AdminStatisticsServiceImpl implements AdminStatisticsService {
         return 1;
     }
 
-    public  List getThisMonth(Days days) {
+    public  List<String> getThisMonth(Days days) {
         //获取当月的第一天
         Date date=new Date();
 
@@ -117,6 +134,7 @@ public class AdminStatisticsServiceImpl implements AdminStatisticsService {
                 list.add(DateUtils.formatDate(newc.getTime(), AFTConstants.YYYYMMDD));
             }else {
                 ca.add(Calendar.DAY_OF_MONTH,1);
+                ca.set(Calendar.HOUR_OF_DAY,0);
                 if (ca.getTimeInMillis()<date.getTime()){
                     Calendar newc=Calendar.getInstance();
                     newc.setTime(ca.getTime());

+ 1 - 1
src/main/java/com/goafanti/common/dao/AdminMapper.java

@@ -180,7 +180,7 @@ public interface AdminMapper {
     List<AdminUserCount> thisMonthUser( @Param("firstDay")String firstDay, @Param("endDay")String endDay,
                                     @Param("aid")String aid);
 
-    List<Integer> thisMonthPublicRelease(@Param("list")List thisMonth,@Param("firstDay")String firstDay, @Param("aid")String aid);
+
 
 
 

+ 2 - 11
src/main/java/com/goafanti/common/mapper/AdminMapper.xml

@@ -1269,23 +1269,14 @@
     group by aid
   </select>
   <select id="thisMonthUser" resultType="com.goafanti.common.model.AdminUserCount">
-    select id,aid,private_count privateCount,sign_count signCount,channel_count channelCount,
+    select id,aid,private_count privateCount,sign_count signCount,channel_count channelCount,public_release_count publicReleaseCount,
            follow_count followCount,order_count orderCount, DATE_FORMAT(date_time , '%Y-%m-%d') dateTime
     from admin_user_count
     where  date_time BETWEEN #{firstDay} and  #{endDay}
       and aid= #{aid}
     order by date_time
   </select>
-  <select id="thisMonthPublicRelease" resultType="java.lang.Integer">
-    <foreach  collection="list" item="e"  index="index" separator="union all">
-    select ifnull(sum(1),0) rangePublicRelease
-    from public_release a left join public_release_details b on a.id=b.prid
-    where status =2 and((a.release_start &gt; #{firstDay} and a.release_start &lt; '${e} 23:59:59')or
-    (a.release_end &gt; #{firstDay} and a.release_end  &lt;  '${e} 23:59:59')or
-    (a.release_start &lt;  #{firstDay} and a.release_end  &gt; '${e} 23:59:59'))
-    and aid= #{aid}
-    </foreach>
-  </select>
+
 
   <select id="selectAdminPublicRelease" resultType="com.goafanti.common.model.AdminUserCount">
     select aid,count(*)publicReleaseCount, dates dateTime

+ 5 - 5
src/main/resources/props/config_local.properties

@@ -1,12 +1,12 @@
 dev.name=local
 jdbc.driverClassName=com.mysql.jdbc.Driver
-jdbc.url=jdbc\:mysql://localhost:3306/aft20221026?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
+#jdbc.url=jdbc\:mysql://localhost:3306/aft20221026?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
 #jdbc.url=jdbc\:mysql://localhost:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
-jdbc.username=root
-jdbc.password=123456
-#jdbc.url=jdbc:mysql://101.37.32.31:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
 #jdbc.username=root
-#jdbc.password=aftdev
+#jdbc.password=123456
+jdbc.url=jdbc:mysql://101.37.32.31:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
+jdbc.username=root
+jdbc.password=aftdev
 jdbc.validationQuery=SELECT 'x'
 jdbc.initialSize=3
 jdbc.maxActive=20