Pārlūkot izejas kodu

巡检管理-巡检记录相关接口上传3

jichaobo 3 gadi atpakaļ
vecāks
revīzija
8db25e6c0f

+ 37 - 3
fiveep-controller/src/main/java/com/bizmatics/controller/web/PatrolInspectionRecordController.java

@@ -3,6 +3,7 @@ package com.bizmatics.controller.web;
 
 import com.bizmatics.common.core.bean.ApiResult;
 import com.bizmatics.common.core.bean.CommonPage;
+import com.bizmatics.model.vo.CurrencyDroplistVo;
 import com.bizmatics.model.vo.PatrolInspectionDeviceVo;
 import com.bizmatics.model.vo.PatrolInspectionRecordDetailsVo;
 import com.bizmatics.model.vo.PatrolInspectionRecordVo;
@@ -19,7 +20,7 @@ import java.util.List;
 
 /**
  * <p>
- * 前端控制器
+ * 巡检记录
  * </p>
  *
  * @author ya
@@ -33,19 +34,52 @@ public class PatrolInspectionRecordController {
     @Autowired
     private PatrolInspectionRecordService patrolInspectionRecordService;
 
+    /**
+     * 巡检管理-巡检记录-按计划查看/按站点查看
+     * @param siteId 站点ID
+     * @param inspectionSchemeId 巡检计划ID
+     * @param size 页数
+     * @param current 条数
+     * @return
+     */
     @GetMapping("patrolInspectionRecordList")
     public ApiResult<CommonPage<PatrolInspectionRecordVo>> patrolInspectionRecordList(@RequestParam(value = "siteId", required = false, defaultValue = "0") Integer siteId,
-                                                                                      @RequestParam(required = false) String inspectionSchemeName,
+                                                                                      @RequestParam(value = "inspectionSchemeId", required = false, defaultValue = "0") Integer inspectionSchemeId,
                                                                                       @RequestParam(value = "size", required = false, defaultValue = "1") Integer size,
                                                                                       @RequestParam(value = "current", required = false, defaultValue = "15") Integer current
     ) {
-        return ApiResult.success(patrolInspectionRecordService.patrolInspectionRecordList(inspectionSchemeName, siteId, size, current));
+        return ApiResult.success(patrolInspectionRecordService.patrolInspectionRecordList(inspectionSchemeId, siteId, size, current));
     }
 
+    /**
+     * 巡检管理-巡检记录-详情查询
+     * @param id 记录ID
+     * @return
+     */
     @GetMapping("patrolInspectionRecordDetails")
     public ApiResult<List<PatrolInspectionRecordDetailsVo>> patrolInspectionRecordDetails(@RequestParam Integer id
     ) {
         return ApiResult.success(patrolInspectionRecordService.patrolInspectionRecordDetails(id));
     }
+
+    /**
+     * 巡检管理-巡检记录-按站点查看下拉框
+     * @return
+     */
+    @GetMapping("patrolInspectionRecordSiteDroplist")
+    public ApiResult<List<CurrencyDroplistVo>> patrolInspectionRecordSiteDroplist(
+    ) {
+        return ApiResult.success(patrolInspectionRecordService.patrolInspectionRecordSiteDroplist());
+    }
+
+    /**
+     * 巡检管理-巡检记录-按计划查看下拉框
+     * @return
+     */
+    @GetMapping("patrolInspectionRecordPlanDroplist")
+    public ApiResult<List<CurrencyDroplistVo>> patrolInspectionRecordPlanDroplist(
+    ) {
+        return ApiResult.success(patrolInspectionRecordService.patrolInspectionRecordPlanDroplist());
+    }
 }
 

+ 40 - 0
fiveep-model/src/main/java/com/bizmatics/model/vo/CurrencyDroplistVo.java

@@ -0,0 +1,40 @@
+package com.bizmatics.model.vo;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author ya
+ * @since 2021-10-19
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class CurrencyDroplistVo {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * ID
+     */
+    private Integer id;
+
+    /**
+     * 名称
+     */
+    private String name;
+
+    /**
+     * 数量
+     */
+    private Integer statisticsCount;
+
+}

+ 6 - 1
fiveep-persistence/src/main/java/com/bizmatics/persistence/mapper/PatrolInspectionRecordMapper.java

@@ -3,6 +3,7 @@ package com.bizmatics.persistence.mapper;
 import com.bizmatics.common.mvc.base.CrudMapper;
 import com.bizmatics.model.PatrolInspectionRecord;
 import com.bizmatics.model.PatrolInspectors;
+import com.bizmatics.model.vo.CurrencyDroplistVo;
 import com.bizmatics.model.vo.PatrolInspectionRecordVo;
 import com.bizmatics.model.vo.PatrolRouteContentListVo;
 import com.bizmatics.model.vo.PatrolRouteContentTimingVo;
@@ -20,7 +21,7 @@ import java.util.List;
  */
 public interface PatrolInspectionRecordMapper extends CrudMapper<PatrolInspectionRecord> {
 
-    List<PatrolInspectionRecordVo> patrolInspectionRecordList(@Param("inspectionSchemeName") String inspectionSchemeName,
+    List<PatrolInspectionRecordVo> patrolInspectionRecordList(@Param("inspectionSchemeId") Integer inspectionSchemeId,
                                                               @Param("siteId") Integer siteId,
                                                               @Param("id") Integer id,
                                                               @Param("startCurrent") Integer startCurrent,
@@ -34,5 +35,9 @@ public interface PatrolInspectionRecordMapper extends CrudMapper<PatrolInspectio
 
     List<PatrolRouteContentTimingVo> patrolRouteContentTimingVoList(@Param("inspectionRouteId") Integer inspectionRouteId);
 
+    List<CurrencyDroplistVo> patrolInspectionRecordSiteDroplist(@Param("userId") Integer userId);
+
+    List<CurrencyDroplistVo> patrolInspectionRecordPlanDroplist();
+
 
 }

+ 66 - 2
fiveep-persistence/src/main/resources/mapper/mysql/PatrolInspectionRecordMapper.xml

@@ -34,8 +34,8 @@
         join patrol_inspection_route as e on a.inspection_route_id=e.id
         <where>
             a.status = 1
-            <if test="inspectionSchemeName != null and inspectionSchemeName !=''">
-                AND b.inspection_scheme_name LIKE CONCAT(CONCAT('%', #{inspectionSchemeName}), '%')
+            <if test="inspectionSchemeId != null and inspectionSchemeId !=0">
+                AND a.inspection_scheme_id = #{inspectionSchemeId}
             </if>
             <if test="siteId != null and siteId !=0 ">
                 AND a.site_id = #{siteId}
@@ -101,4 +101,68 @@
         </where>
     </select>
 
+    <select id="patrolInspectionRecordSiteDroplist" resultType="com.bizmatics.model.vo.CurrencyDroplistVo">
+        SELECT
+        c.id,
+        c.site_name as name,
+
+        IF (
+        d.record_count &lt;&gt; '',
+        d.record_count,
+        0
+        ) AS statistics_count
+        FROM
+        user_site AS b
+        JOIN site AS c ON b.site_id = c.id
+        LEFT JOIN (
+        SELECT
+        a.id,
+        a.site_name,
+        COUNT(a.id) AS record_count
+        FROM
+        site AS a
+        JOIN patrol_inspection_record AS b ON a.id = b.site_id
+        <where>
+            b.status = 1
+        </where>
+        GROUP BY
+        a.id
+        ) AS d ON c.id = d.id
+        <where>
+            c.enable = 1
+            <if test="userId != null and userId != 0">
+                and b.user_id = #{userId}
+            </if>
+        </where>
+    </select>
+
+    <select id="patrolInspectionRecordPlanDroplist" resultType="com.bizmatics.model.vo.CurrencyDroplistVo">
+        SELECT
+        c.id,
+        c.inspection_scheme_name as name,
+
+        IF (
+        d.statistics_count &lt;&gt; '',
+        d.statistics_count,
+        0
+        ) AS statistics_count
+        FROM
+        patrol_inspection_scheme AS c
+        LEFT JOIN (
+        SELECT
+        a.id,
+        a.inspection_scheme_name,
+        COUNT(b.id) AS statistics_count
+        FROM
+        patrol_inspection_scheme AS a
+        JOIN patrol_inspection_record AS b ON a.id = b.inspection_scheme_id
+        <where>
+        a.status = 1
+        AND b.status = 1
+        </where>
+        GROUP BY
+        a.id
+        ) AS d ON c.id = d.id
+    </select>
+
 </mapper>

+ 6 - 1
fiveep-service/src/main/java/com/bizmatics/service/PatrolInspectionRecordService.java

@@ -3,6 +3,7 @@ package com.bizmatics.service;
 import com.bizmatics.common.core.bean.CommonPage;
 import com.bizmatics.model.PatrolInspectionRecord;
 import com.bizmatics.common.mvc.base.CrudService;
+import com.bizmatics.model.vo.CurrencyDroplistVo;
 import com.bizmatics.model.vo.PatrolInspectionRecordDetailsVo;
 import com.bizmatics.model.vo.PatrolInspectionRecordVo;
 
@@ -18,7 +19,11 @@ import java.util.List;
  */
 public interface PatrolInspectionRecordService extends CrudService<PatrolInspectionRecord> {
 
-    CommonPage<PatrolInspectionRecordVo> patrolInspectionRecordList(String inspectionSchemeName, Integer siteId, Integer size, Integer current);
+    CommonPage<PatrolInspectionRecordVo> patrolInspectionRecordList(Integer inspectionSchemeId, Integer siteId, Integer size, Integer current);
 
     List<PatrolInspectionRecordDetailsVo> patrolInspectionRecordDetails(Integer id);
+
+    List<CurrencyDroplistVo> patrolInspectionRecordSiteDroplist();
+
+    List<CurrencyDroplistVo> patrolInspectionRecordPlanDroplist();
 }

+ 19 - 4
fiveep-service/src/main/java/com/bizmatics/service/impl/PatrolInspectionRecordServiceImpl.java

@@ -4,14 +4,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.bizmatics.common.core.bean.CommonPage;
 import com.bizmatics.model.PatrolInspectionRecord;
-import com.bizmatics.model.PatrolInspectionScheme;
 import com.bizmatics.model.PatrolInspectors;
 import com.bizmatics.model.PatrolRecordRoute;
+import com.bizmatics.model.system.SysUser;
 import com.bizmatics.model.vo.*;
 import com.bizmatics.persistence.mapper.PatrolInspectionRecordMapper;
 import com.bizmatics.service.PatrolInspectionRecordService;
 import com.bizmatics.common.mvc.base.AbstractCrudService;
 import com.bizmatics.service.PatrolRecordRouteService;
+import com.bizmatics.service.util.SecurityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -33,14 +34,14 @@ public class PatrolInspectionRecordServiceImpl extends AbstractCrudService<Patro
     private PatrolRecordRouteService patrolRecordRouteService;
 
     @Override
-    public CommonPage<PatrolInspectionRecordVo> patrolInspectionRecordList(String inspectionSchemeName, Integer siteId, Integer size, Integer current) {
-        List<PatrolInspectionRecordVo> patrolInspectionRecordListOne = baseMapper.patrolInspectionRecordList(inspectionSchemeName, siteId, 0, 0, 0);
+    public CommonPage<PatrolInspectionRecordVo> patrolInspectionRecordList(Integer inspectionSchemeId, Integer siteId, Integer size, Integer current) {
+        List<PatrolInspectionRecordVo> patrolInspectionRecordListOne = baseMapper.patrolInspectionRecordList(inspectionSchemeId, siteId, 0, 0, 0);
         int total = 0;
         if (patrolInspectionRecordListOne.size() > 0) {
             total = patrolInspectionRecordListOne.size();
         }
         int startCurrent = (size - 1) * current;
-        List<PatrolInspectionRecordVo> correspondDeviceList = baseMapper.patrolInspectionRecordList(inspectionSchemeName, siteId, 0, startCurrent, current);
+        List<PatrolInspectionRecordVo> correspondDeviceList = baseMapper.patrolInspectionRecordList(inspectionSchemeId, siteId, 0, startCurrent, current);
         return new CommonPage<>(correspondDeviceList, total, current, size);
     }
 
@@ -104,4 +105,18 @@ public class PatrolInspectionRecordServiceImpl extends AbstractCrudService<Patro
 
         return list;
     }
+
+
+    @Override
+    public List<CurrencyDroplistVo> patrolInspectionRecordSiteDroplist(){
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        List<CurrencyDroplistVo> list = baseMapper.patrolInspectionRecordSiteDroplist(new Long(user.getUserId()).intValue());
+        return list;
+    }
+
+    @Override
+    public List<CurrencyDroplistVo> patrolInspectionRecordPlanDroplist(){
+        List<CurrencyDroplistVo> list = baseMapper.patrolInspectionRecordPlanDroplist();
+        return list;
+    }
 }