王苗苗 3 kuukautta sitten
vanhempi
commit
5aa4000cd6

+ 17 - 2
slibra-common/src/main/java/com/slibra/common/utils/DateUtils.java

@@ -225,6 +225,20 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     }
 
 
+    public static String plusDate(int day, Date current, String format)
+    {
+
+        // 创建一个Calendar实例,并将日期设置为今天
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(current);
+        // 将日期设置为前一天
+        calendar.add(Calendar.DATE, day);
+
+        // 转换
+        return parseDateToStr(format, calendar.getTime());
+    }
+
+
     public static List<String> getAllDatesBetween(LocalDate startDate, LocalDate endDate) {
         List<String> dates = new ArrayList<>();
         LocalDate currentDate = startDate;
@@ -340,7 +354,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
         /*System.out.println(getMonthsBefore("2024-02", 2));
         System.out.println();
         System.out.println(getNYearSameDay("2024-02-01", 1));
-        System.out.println(getNYearSameMonth("2024-02", 1));*/
+        System.out.println(getNYearSameMonth("2024-02", 1));
         List<String> allDatesInRangeDate = getAllDatesInRangeDate(date1, date);
         for (String s : allDatesInRangeDate) {
             System.out.println(s);
@@ -355,6 +369,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
             }
         } catch (Exception e) {
             e.printStackTrace();
-        }
+        }*/
+        System.out.println(plusDate(-1, nowDate, YYYY_MM_DD));
     }
 }

+ 4 - 0
slibra-system/src/main/java/com/slibra/business/mapper/TCallRecordMapper.java

@@ -98,4 +98,8 @@ public interface TCallRecordMapper
     List<CallUserCountInfo> selectAllPersonUserIds();
 
     int getTotalInByType(@Param("type") Integer type, @Param("date") String date);
+
+    int getRecentCallRecordAfterSomeDay(@Param("type") Integer type, @Param("date") String date);
+
+    long getRecentCallTimes(String date);
 }

+ 15 - 0
slibra-system/src/main/java/com/slibra/business/service/impl/TCallRecordServiceImpl.java

@@ -27,6 +27,7 @@ import com.slibra.business.service.ITCallRecordService;
 import org.springframework.util.CollectionUtils;
 
 import static com.slibra.common.constant.MyConstants.*;
+import static com.slibra.common.utils.DateUtils.YYYY_MM_DD;
 
 /**
  * 通话记录Service业务层处理
@@ -530,6 +531,20 @@ public class TCallRecordServiceImpl implements ITCallRecordService
     @Override
     public HomeCountResp homeScreenCount() {
         HomeCountResp build = HomeCountResp.builder().build();
+        //获取7天前的日期
+        String lastDate = DateUtils.plusDate(-1, DateUtils.getNowDate(), YYYY_MM_DD);
+        //查询说明: type未空是查询所有呼入的 0:成功接通的
+        int inTotal = this.tCallRecordMapper.getRecentCallRecordAfterSomeDay(null, lastDate);
+        build.setInTotal(inTotal);
+        int inTotalSuccess = this.tCallRecordMapper.getRecentCallRecordAfterSomeDay(0, lastDate);
+        if(inTotal > 0)
+            build.setSuccessRate(DecimalUtils.getNLengthHalfUp(new BigDecimal(inTotalSuccess/(double)inTotal).multiply(BigDecimal_100), INT_2));
+        long inTimes = this.tCallRecordMapper.getRecentCallTimes(lastDate);
+        build.setInTimes(inTimes);
+        if(inTotalSuccess > 0)
+            build.setInTimesAvg(inTimes/inTotalSuccess);
+        build.setTotalTimes(this.tCallRecordMapper.getRecentCallTimes(null));
+        build.setTotalCounts(this.tCallRecordMapper.getRecentCallRecordAfterSomeDay(null, null));
 
         return build;
     }

+ 51 - 0
slibra-system/src/main/resources/mapper/business/TCallRecordMapper.xml

@@ -420,4 +420,55 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             </choose>
         </if>
     </select>
+
+    <select id="getRecentCallRecordAfterSomeDay" resultType="int">
+        SELECT
+        COUNT(*)
+        FROM
+        t_call_record
+        WHERE
+        del_flag = 0
+        AND category = 0
+        <if test="date != null and date != ''">
+            AND DATE_FORMAT(create_time, '%Y-%m-%d') >= #{date}
+        </if>
+        <if test="type != null ">
+            <choose>
+                <when test="0 == type">
+                    AND status = 1
+                </when>
+                <!--<when test="1 == type">
+                    AND status = 0
+                </when>
+                <when test="2 == type">
+                    AND (service_category = 1 or service_category = 2)
+                </when>
+                <when test="3 == type">
+                    AND service_category = 2
+                </when>
+                <when test="4 == type">
+                    AND service_category = 0
+                </when>
+                <when test="5 == type">
+                    AND service_category = 1
+                </when>
+                <when test="6 == type">
+                    AND (service_category = 2 or service_category = 0)
+                </when>-->
+            </choose>
+        </if>
+    </select>
+
+    <select id="getRecentCallTimes" resultType="long">
+        SELECT
+            IFNULL( SUM( times ), 0 )
+        FROM
+            t_call_record
+        WHERE
+            del_flag = 0
+          AND category = 0
+        <if test="date != null and date != ''">
+          AND DATE_FORMAT( create_time, '%Y-%m-%d' ) >= #{date}
+        </if>
+    </select>
 </mapper>