Browse Source

小程序数据统计-年检管理

黄远 5 years ago
parent
commit
8962a8170c

+ 2 - 2
lift-batch-service/src/main/java/cn/com/ty/lift/batch/applet/controller/AnnualInspectionDataStatisticsController.java

@@ -43,8 +43,8 @@ public class AnnualInspectionDataStatisticsController {
     }
 
     /**
-     * @param annualInspectionDataRequest
-     * @return
+     * @param annualInspectionDataRequest 请求数据
+     * @return 年检数据
      * @description 获取项目下年检电梯的信息
      * @date 2020/5/23 10:10 上午
      */

+ 2 - 0
lift-batch-service/src/main/java/cn/com/ty/lift/batch/applet/dao/model/AnnualInspectionDataModel.java

@@ -2,6 +2,7 @@ package cn.com.ty.lift.batch.applet.dao.model;
 
 import cn.com.ty.lift.batch.applet.constants.DataStatisticsConstants;
 import lombok.Data;
+import lombok.EqualsAndHashCode;
 import org.apache.commons.lang3.StringUtils;
 
 import java.time.LocalDate;
@@ -12,6 +13,7 @@ import java.time.format.DateTimeFormatter;
  * @date 2020/2/3
  * @description
  */
+@EqualsAndHashCode(callSuper = true)
 @Data
 public class AnnualInspectionDataModel extends BaseDataModel {
     /**

+ 10 - 0
lift-batch-service/src/main/java/cn/com/ty/lift/batch/applet/dao/model/request/AnnualInspectionDataRequest.java

@@ -19,4 +19,14 @@ public class AnnualInspectionDataRequest extends CommonRequest {
      */
     private String projectId;
 
+    /**
+     * 页数
+     */
+    private Long pageNum;
+
+    /**
+     * 每页的条数
+     */
+    private Long pageSize;
+
 }

+ 3 - 1
lift-batch-service/src/main/java/cn/com/ty/lift/batch/applet/service/AnnualInspectionDataService.java

@@ -89,7 +89,8 @@ public class AnnualInspectionDataService {
         //封装台量
         projectAnnualList.forEach(annualInspectionDataModel -> {
             if (projectIdToLiftNum != null && projectIdToLiftNum.size() > 0) {
-                annualInspectionDataModel.setUnitNum(projectIdToLiftNum.get(annualInspectionDataModel.getProjectId()));
+                annualInspectionDataModel.setUnitNum(DataStatisticsUtil.getLongValue(
+                        projectIdToLiftNum.get(annualInspectionDataModel.getProjectId())));
             }
         });
         return RestResponse.success(projectAnnualList, ApiConstants.RESULT_SUCCESS, "获取统计数据成功");
@@ -102,6 +103,7 @@ public class AnnualInspectionDataService {
      * @date 2020/5/23 10:02 上午
      */
     public RestResponse liftAnnualInfo(AnnualInspectionDataRequest annualInspectionDataRequest) {
+        DataStatisticsUtil.initCommonRequest(annualInspectionDataRequest);
         List<AnnualInspectionDataModel> liftAnnualList = annualInspectionDataMapper
                 .getProjectLiftAnnualInfo(annualInspectionDataRequest);
         return RestResponse.success(liftAnnualList);

+ 13 - 0
lift-batch-service/src/main/java/cn/com/ty/lift/batch/applet/util/DataStatisticsUtil.java

@@ -302,4 +302,17 @@ public class DataStatisticsUtil {
         commonRequest.setStartTimeDateStr(yearStartTime);
         commonRequest.setEndTimeDateStr(nowEndTime);
     }
+
+    /**
+     * @param value 值
+     * @return long 值
+     * @description 去除空值的情况
+     * @date 2020/4/24 5:18 下午
+     */
+    public static long getLongValue(Long value) {
+        if (value != null) {
+            return value;
+        }
+        return 0L;
+    }
 }

+ 21 - 0
lift-batch-service/src/main/resources/mapper/AnnualInspectionDataMapper.xml

@@ -37,6 +37,23 @@
             p.project_name as projectName
         from
             project p
+        left join
+            project_lift_relevance plr
+        on
+            p.id = plr.project_id
+        left join
+            annual_inspection ai
+        on
+            plr.lift_id = ai.lift_id
+        where
+            p.project_status <![CDATA[ != ]]> '3'
+        and
+            p.mt_company_id = #{mtCompanyId}
+        and
+            ai.plan_date <![CDATA[ >= ]]> #{startTimeDateStr}
+        and
+            ai.plan_date <![CDATA[ <= ]]> #{endTimeDateStr}
+        limit #{pageNum}, #{pageSize}
     </select>
 
     <!-- 获取项目下的电梯年检状态 -->
@@ -61,6 +78,10 @@
             ai.mt_company_id = #{mtCompanyId}
         and
             plr.project_id = #{projectId}
+        and
+            ai.plan_date <![CDATA[ >= ]]> #{startTimeDateStr}
+        and
+            ai.plan_date <![CDATA[ <= ]]> #{endTimeDateStr}
     </select>
 
     <!-- 获取项目关联的电梯 -->