Bläddra i källkod

企业数据统计

黄远 5 år sedan
förälder
incheckning
6888d987c6

+ 2 - 1
lift-system-service/src/main/java/cn/com/ty/lift/system/homepage/controller/EnterpriseDataStatisticsController.java

@@ -3,6 +3,7 @@ package cn.com.ty.lift.system.homepage.controller;
 import cn.com.ty.lift.system.homepage.dao.dto.request.DataStatisticsRequest;
 import cn.com.ty.lift.system.homepage.service.EnterpriseDataStatisticsService;
 import cn.com.xwy.boot.web.dto.RestResponse;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -27,7 +28,7 @@ public class EnterpriseDataStatisticsController {
      * @date 2020/4/24 10:27 上午
      */
     @RequestMapping("/yearBusinessData")
-    public RestResponse yearBusinessData(DataStatisticsRequest dataStatisticsRequest) {
+    public RestResponse yearBusinessData(@RequestBody DataStatisticsRequest dataStatisticsRequest) {
         return enterpriseDataStatisticsService.yearBusinessData(dataStatisticsRequest);
     }
 }

+ 1 - 1
lift-system-service/src/main/java/cn/com/ty/lift/system/homepage/service/EnterpriseDataStatisticsService.java

@@ -78,7 +78,7 @@ public class EnterpriseDataStatisticsService {
      */
     private void initDataStatisticsRequest(DataStatisticsRequest dataStatisticsRequest) {
         LocalDate now = LocalDate.now();
-        LocalDate beforeYear = now.plusDays(-YEAR_INTERVAL);
+        LocalDate beforeYear = now.plusYears(-YEAR_INTERVAL);
         DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(CommonConstants.PLAN_DATE_FORMAT);
         dataStatisticsRequest.setNowDateStr(now.format(dateTimeFormatter));
         dataStatisticsRequest.setBeforeDateStr(beforeYear.format(dateTimeFormatter));

+ 14 - 10
lift-system-service/src/main/resources/mapper/CommonDataMapper.xml

@@ -245,14 +245,15 @@
             SUBSTR(create_date, 1, 4) as year,
             count(create_date) as dataCount
         from project
-        group by
-            SUBSTR(create_date, 1, 4)
         where
             mt_company_id = #{companyId}
         and
             create_date <![CDATA[ >= ]]> #{beforeDateStr}
         and
             create_date <![CDATA[ <= ]]> #{nowDateStr}
+        group by
+            SUBSTR(create_date, 1, 4)
+
     </select>
 
     <!--获取 年份-维保次数 -->
@@ -263,14 +264,15 @@
             SUBSTR(create_date, 1, 4) as year,
             count(create_date) as dataCount
         from maintenance_record
-        group by
-            SUBSTR(create_date, 1, 4)
         where
             mt_company_id = #{companyId}
         and
             create_date <![CDATA[ >= ]]> #{beforeDateStr}
         and
             create_date <![CDATA[ <= ]]> #{nowDateStr}
+        group by
+            SUBSTR(create_date, 1, 4)
+
     </select>
     <!--获取 年份-急修次数 -->
     <select id="getEveryYearEmergencyCount"
@@ -280,14 +282,15 @@
             SUBSTR(create_date, 1, 4) as year,
             count(create_date) as dataCount
         from emergency_repair
-        group by
-            SUBSTR(create_date, 1, 4)
         where
             mt_company_id = #{companyId}
         and
             create_date <![CDATA[ >= ]]> #{beforeDateStr}
         and
             create_date <![CDATA[ <= ]]> #{nowDateStr}
+        group by
+            SUBSTR(create_date, 1, 4)
+
     </select>
     <!--获取 年份-年检次数 -->
     <select id="getEveryYearAnnualCount"
@@ -297,14 +300,15 @@
             SUBSTR(create_date, 1, 4) as year,
             count(create_date) as dataCount
         from annual_inspection
-        group by
-            SUBSTR(create_date, 1, 4)
         where
             mt_company_id = #{companyId}
         and
             create_date <![CDATA[ >= ]]> #{beforeDateStr}
         and
             create_date <![CDATA[ <= ]]> #{nowDateStr}
+        group by
+            SUBSTR(create_date, 1, 4)
+
     </select>
     <!--获取 年份-大修次数 -->
     <select id="getEveryYearCapitalCount"
@@ -314,14 +318,14 @@
             SUBSTR(create_date, 1, 4) as year,
             count(create_date) as dataCount
         from capital_repair
-        group by
-            SUBSTR(create_date, 1, 4)
         where
             mt_company_id = #{companyId}
         and
             create_date <![CDATA[ >= ]]> #{beforeDateStr}
         and
             create_date <![CDATA[ <= ]]> #{nowDateStr}
+        group by
+            SUBSTR(create_date, 1, 4)
     </select>
 
 </mapper>