Browse Source

fix: 系统使用数据统计查询fix

zhangying 9 months ago
parent
commit
5d0c531de6

+ 17 - 0
src/main/java/com/hz/employmentsite/controller/statistics/StatisticsController.java

@@ -54,6 +54,23 @@ public class StatisticsController {
     public BaseResponse exportSystemApplyCount(HttpServletResponse response,
                                                @RequestParam(value = "startDate", required = false) Date startDate,
                                                @RequestParam(value = "endDate", required = false) Date endDate) throws Exception {
+        if (startDate != null) {
+            Calendar startCal = Calendar.getInstance();
+            startCal.setTime(startDate);
+            startCal.set(Calendar.HOUR_OF_DAY, 0);
+            startCal.set(Calendar.MINUTE, 0);
+            startCal.set(Calendar.SECOND, 0);
+            startDate = startCal.getTime();
+        }
+
+        if (endDate != null) {
+            Calendar endCal = Calendar.getInstance();
+            endCal.setTime(endDate);
+            endCal.set(Calendar.HOUR_OF_DAY, 23);
+            endCal.set(Calendar.MINUTE, 59);
+            endCal.set(Calendar.SECOND, 59);
+            endDate = endCal.getTime();
+        }
         List<SystemDataCount> systemDataCount = statisticsService.findSystemDataCount(startDate, endDate);
         ExcelHelper.ExcelData data = excelHelper.new ExcelData();
         Map<String, CellRangeAddress> titleMap = new HashMap<>();

+ 6 - 6
src/main/resources/mapping/cquery/StatisticsCQuery.xml

@@ -18,10 +18,10 @@
         WHERE
         SiteID = site.SiteID
         <if test="startDate != null">
-            and CreateTime <![CDATA[ >= ]]> #{startDate}
+            and DATE(CreateTime) <![CDATA[ >= ]]> DATE(#{startDate})
         </if>
         <if test="endDate != null ">
-            and CreateTime <![CDATA[ <= ]]> #{endDate}
+            and DATE(CreateTime) <![CDATA[ <= ]]> DATE(#{endDate})
         </if>
         ) AS companyCount,
         -- 指定时间段的登记岗位数量
@@ -33,10 +33,10 @@
         WHERE
         CompanyID IN ( SELECT company.CompanyID FROM pc_company company WHERE company.SiteID = site.SiteID )
         <if test="startDate != null">
-            and CreateTime <![CDATA[ >= ]]> #{startDate}
+            and DATE(CreateTime) <![CDATA[ >= ]]> DATE(#{startDate})
         </if>
         <if test="endDate != null ">
-            and CreateTime <![CDATA[ <= ]]> #{endDate}
+            and DATE(CreateTime) <![CDATA[ <= ]]> DATE(#{endDate})
         </if>
         ) AS postCount,
         -- 指定时间段的登记求职人员数量
@@ -48,10 +48,10 @@
         WHERE
         SiteID = site.SiteID
         <if test="startDate != null">
-            and CreateTime <![CDATA[ >= ]]> #{startDate}
+            and DATE(CreateTime) <![CDATA[ >= ]]> DATE(#{startDate})
         </if>
         <if test="endDate != null ">
-            and CreateTime <![CDATA[ <= ]]> #{endDate}
+            and DATE(CreateTime) <![CDATA[ <= ]]> DATE(#{endDate})
         </if>
         ) AS jobUserCount
         FROM