Pārlūkot izejas kodu

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

jichaobo 3 gadi atpakaļ
vecāks
revīzija
5717a6efcb

+ 51 - 0
fiveep-controller/src/main/java/com/bizmatics/controller/web/PatrolInspectionRecordController.java

@@ -0,0 +1,51 @@
+package com.bizmatics.controller.web;
+
+
+import com.bizmatics.common.core.bean.ApiResult;
+import com.bizmatics.common.core.bean.CommonPage;
+import com.bizmatics.model.vo.PatrolInspectionDeviceVo;
+import com.bizmatics.model.vo.PatrolInspectionRecordDetailsVo;
+import com.bizmatics.model.vo.PatrolInspectionRecordVo;
+import com.bizmatics.service.PatrolInspectionRecordService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 前端控制器
+ * </p>
+ *
+ * @author ya
+ * @since 2021-10-20
+ */
+@RestController
+@RequestMapping("/patrolInspectionRecord")
+public class PatrolInspectionRecordController {
+
+
+    @Autowired
+    private PatrolInspectionRecordService patrolInspectionRecordService;
+
+    @GetMapping("patrolInspectionRecordList")
+    public ApiResult<CommonPage<PatrolInspectionRecordVo>> patrolInspectionRecordList(@RequestParam(value = "siteId", required = false, defaultValue = "0") Integer siteId,
+                                                                                      @RequestParam(required = false) String inspectionSchemeName,
+                                                                                      @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));
+    }
+
+    @GetMapping("patrolInspectionRecordDetails")
+    public ApiResult<List<PatrolInspectionRecordDetailsVo>> patrolInspectionRecordDetails(@RequestParam Integer id
+    ) {
+        return ApiResult.success(patrolInspectionRecordService.patrolInspectionRecordDetails(id));
+    }
+}
+

+ 92 - 0
fiveep-model/src/main/java/com/bizmatics/model/PatrolInspectionRecord.java

@@ -0,0 +1,92 @@
+package com.bizmatics.model;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.time.LocalDateTime;
+import java.io.Serializable;
+import java.util.Date;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author ya
+ * @since 2021-10-20
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class PatrolInspectionRecord implements Serializable {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 巡检记录id
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 巡检计划id
+     */
+    private Integer inspectionSchemeId;
+
+    /**
+     * 巡检班组id
+     */
+    private Integer inspectionTeamId;
+
+    /**
+     * 启动时间
+     */
+    private Date startTime;
+
+    /**
+     * 巡检次数
+     */
+    private Integer inspectionNumber;
+
+    /**
+     * 站点数
+     */
+    private Integer siteId;
+
+    /**
+     * 巡检进度
+     */
+    private Double inspectionSchedule;
+
+    /**
+     * 完成时间
+     */
+    private Date completionTime;
+
+    /**
+     * 巡检结果
+     */
+    private String inspectionResult;
+
+    /**
+     * 创建人
+     */
+    private String creator;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    /**
+     * 启用状态(0 未进行,1 进行中,2 已完成)
+     */
+    private Integer status;
+
+    private Integer inspectionRouteId;
+
+
+}

+ 85 - 0
fiveep-model/src/main/java/com/bizmatics/model/PatrolRecordRoute.java

@@ -0,0 +1,85 @@
+package com.bizmatics.model;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.time.LocalDateTime;
+import java.io.Serializable;
+import java.util.Date;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author ya
+ * @since 2021-10-20
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class PatrolRecordRoute implements Serializable {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 巡检记录线路关联表ID
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 巡检计划ID
+     */
+    private Integer inspectionSchemeId;
+
+    /**
+     * 巡检线路ID
+     */
+    private Integer inspectionRouteId;
+
+    /**
+     * 巡检记录ID
+     */
+    private Integer inspectionRecordId;
+
+    /**
+     * 添加人
+     */
+    private String creator;
+
+    /**
+     * 添加时间
+     */
+    private Date createTime;
+
+    /**
+     * 状态(0 待巡检,1 正常 ,2 异常)
+     */
+    private Integer status;
+
+    /**
+     * 检查项
+     */
+    private String checkEntryName;
+
+    /**
+     * 描述
+     */
+    private String represent;
+
+    /**
+     * 图片路径
+     */
+    private String picturePath;
+
+    /**
+     * 巡检内容ID
+     */
+    private Integer inspectionContentId;
+
+
+}

+ 38 - 0
fiveep-persistence/src/main/java/com/bizmatics/persistence/mapper/PatrolInspectionRecordMapper.java

@@ -0,0 +1,38 @@
+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.PatrolInspectionRecordVo;
+import com.bizmatics.model.vo.PatrolRouteContentListVo;
+import com.bizmatics.model.vo.PatrolRouteContentTimingVo;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * <p>
+ * Mapper 接口
+ * </p>
+ *
+ * @author ya
+ * @since 2021-10-20
+ */
+public interface PatrolInspectionRecordMapper extends CrudMapper<PatrolInspectionRecord> {
+
+    List<PatrolInspectionRecordVo> patrolInspectionRecordList(@Param("inspectionSchemeName") String inspectionSchemeName,
+                                                              @Param("siteId") Integer siteId,
+                                                              @Param("id") Integer id,
+                                                              @Param("startCurrent") Integer startCurrent,
+                                                              @Param("current") Integer current);
+
+    List<PatrolInspectors> patrolInspectorsList(@Param("teamId") Integer teamId);
+
+
+    List<PatrolRouteContentListVo> patrolRouteContentList(@Param("siteId") Integer siteId,
+                                                          @Param("inspectionSchemeId") Integer inspectionSchemeId);
+
+    List<PatrolRouteContentTimingVo> patrolRouteContentTimingVoList(@Param("inspectionRouteId") Integer inspectionRouteId);
+
+
+}

+ 16 - 0
fiveep-persistence/src/main/java/com/bizmatics/persistence/mapper/PatrolRecordRouteMapper.java

@@ -0,0 +1,16 @@
+package com.bizmatics.persistence.mapper;
+
+import com.bizmatics.model.PatrolRecordRoute;
+import com.bizmatics.common.mvc.base.CrudMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author ya
+ * @since 2021-10-20
+ */
+public interface PatrolRecordRouteMapper extends CrudMapper<PatrolRecordRoute> {
+
+}

+ 104 - 0
fiveep-persistence/src/main/resources/mapper/mysql/PatrolInspectionRecordMapper.xml

@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.bizmatics.persistence.mapper.PatrolInspectionRecordMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.bizmatics.model.PatrolInspectionRecord">
+        <id column="id" property="id" />
+        <result column="inspection_scheme_id" property="inspectionSchemeId" />
+        <result column="inspection_team_id" property="inspectionTeamId" />
+        <result column="start_time" property="startTime" />
+        <result column="inspection_number" property="inspectionNumber" />
+        <result column="site_id" property="siteId" />
+        <result column="inspection_schedule" property="inspectionSchedule" />
+        <result column="completion_time" property="completionTime" />
+        <result column="inspection_result" property="inspectionResult" />
+        <result column="creator" property="creator" />
+        <result column="create_time" property="createTime" />
+        <result column="status" property="status" />
+    </resultMap>
+
+    <select id="patrolInspectionRecordList" resultType="com.bizmatics.model.vo.PatrolInspectionRecordVo">
+        SELECT
+        a.*, b.inspection_scheme_name,
+        c.team_name,
+        d.site_name,
+        c.inspectors_id,
+        b.execution_time,
+        e.inspection_route_name
+        FROM
+        patrol_inspection_record AS a
+        JOIN patrol_inspection_scheme AS b ON a.inspection_scheme_id = b.id
+        JOIN patrol_inspection_team AS c ON a.inspection_team_id = c.id
+        JOIN site AS d ON a.site_id = d.id
+        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>
+            <if test="siteId != null and siteId !=0 ">
+                AND a.site_id = #{siteId}
+            </if>
+            <if test="id != null and id !=0 ">
+                AND a.id = #{id}
+            </if>
+        </where>
+        ORDER BY
+        a.id DESC
+        <if test="startCurrent != 0 and current !=0">
+            LIMIT #{startCurrent},
+            #{current}
+        </if>
+    </select>
+
+    <select id="patrolInspectorsList" resultType="com.bizmatics.model.PatrolInspectors">
+        SELECT
+        b.*
+        FROM
+        patrol_team_inspection AS a
+        JOIN patrol_inspectors AS b ON a.inspectors_id = b.id
+        <where>
+            a.status = 1
+            <if test="teamId != null and teamId != 0">
+                AND a.team_id = #{teamId}
+            </if>
+        </where>
+    </select>
+
+    <select id="patrolRouteContentList" resultType="com.bizmatics.model.vo.PatrolRouteContentListVo">
+        SELECT
+        a.*, c.inspection_content_name,d.inspection_device_name
+        FROM
+        patrol_route_content AS a
+        JOIN patrol_inspection_route AS b ON a.inspection_route_id = b.id
+        JOIN patrol_inspection_content AS c ON a.inspection_content_id = c.id
+        join patrol_inspection_device as d on c.inspection_device_id=d.id
+        <where>
+            a.status = 1
+            AND b.status = 1
+            <if test="inspectionSchemeId != null and inspectionSchemeId != 0">
+                AND b.inspection_scheme_id = #{inspectionSchemeId}
+            </if>
+            <if test="siteId != null and siteId != 0">
+               and b.site_id = #{siteId}
+            </if>
+        </where>
+    </select>
+
+    <select id="patrolRouteContentTimingVoList" resultType="com.bizmatics.model.vo.PatrolRouteContentTimingVo">
+        SELECT
+        a.*, b.check_entry_name
+        FROM
+        patrol_route_content AS s
+        JOIN patrol_content_entry AS a ON s.inspection_content_id = a.inspection_content_id
+        JOIN patrol_check_entry AS b ON a.check_entry_id = b.id
+        <where>
+            a. STATUS = 1
+            <if test="inspectionRouteId != null and inspectionRouteId != 0">
+                AND s.inspection_route_id = #{inspectionRouteId}
+            </if>
+        </where>
+    </select>
+
+</mapper>

+ 20 - 0
fiveep-persistence/src/main/resources/mapper/mysql/PatrolRecordRouteMapper.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.bizmatics.persistence.mapper.PatrolRecordRouteMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.bizmatics.model.PatrolRecordRoute">
+        <id column="id" property="id" />
+        <result column="inspection_scheme_id" property="inspectionSchemeId" />
+        <result column="inspection_route_id" property="inspectionRouteId" />
+        <result column="inspection_record_id" property="inspectionRecordId" />
+        <result column="creator" property="creator" />
+        <result column="create_time" property="createTime" />
+        <result column="status" property="status" />
+        <result column="check_entry_name" property="checkEntryName" />
+        <result column="represent" property="represent" />
+        <result column="picture_path" property="picturePath" />
+        <result column="inspection_content_id" property="inspectionContentId" />
+    </resultMap>
+
+</mapper>

+ 24 - 0
fiveep-service/src/main/java/com/bizmatics/service/PatrolInspectionRecordService.java

@@ -0,0 +1,24 @@
+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.PatrolInspectionRecordDetailsVo;
+import com.bizmatics.model.vo.PatrolInspectionRecordVo;
+
+import java.util.List;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author ya
+ * @since 2021-10-20
+ */
+public interface PatrolInspectionRecordService extends CrudService<PatrolInspectionRecord> {
+
+    CommonPage<PatrolInspectionRecordVo> patrolInspectionRecordList(String inspectionSchemeName, Integer siteId, Integer size, Integer current);
+
+    List<PatrolInspectionRecordDetailsVo> patrolInspectionRecordDetails(Integer id);
+}

+ 16 - 0
fiveep-service/src/main/java/com/bizmatics/service/PatrolRecordRouteService.java

@@ -0,0 +1,16 @@
+package com.bizmatics.service;
+
+import com.bizmatics.model.PatrolRecordRoute;
+import com.bizmatics.common.mvc.base.CrudService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author ya
+ * @since 2021-10-20
+ */
+public interface PatrolRecordRouteService extends CrudService<PatrolRecordRoute> {
+
+}

+ 107 - 0
fiveep-service/src/main/java/com/bizmatics/service/impl/PatrolInspectionRecordServiceImpl.java

@@ -0,0 +1,107 @@
+package com.bizmatics.service.impl;
+
+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.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 org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <p>
+ * 巡检记录
+ * </p>
+ *
+ * @author ya
+ * @since 2021-10-20
+ */
+@Service
+public class PatrolInspectionRecordServiceImpl extends AbstractCrudService<PatrolInspectionRecordMapper, PatrolInspectionRecord> implements PatrolInspectionRecordService {
+
+    @Autowired
+    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);
+        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);
+        return new CommonPage<>(correspondDeviceList, total, current, size);
+    }
+
+    @Override
+    public List<PatrolInspectionRecordDetailsVo> patrolInspectionRecordDetails(Integer id) {
+        List<PatrolRouteContentListVo> patrolRouteContentListVoList = new ArrayList<>();
+        Integer inspectionDeviceAbnormalCount = 0;
+        //记录查询
+        List<PatrolInspectionRecordVo> patrolInspectionRecordList = baseMapper.patrolInspectionRecordList(null, 0, id, 0, 0);
+        //团队人员查询
+        List<PatrolInspectors> PatrolInspectorsList = baseMapper.patrolInspectorsList(patrolInspectionRecordList.get(0).getInspectionTeamId());
+        List<PatrolRouteContentListVo> patrolRouteContentList = baseMapper.patrolRouteContentList(patrolInspectionRecordList.get(0).getSiteId(), patrolInspectionRecordList.get(0).getInspectionSchemeId());
+        for (int i= 0; i<patrolRouteContentList.size();i++){
+
+            LambdaQueryWrapper<PatrolRecordRoute> queryWrapper = Wrappers.lambdaQuery();
+            queryWrapper.eq(PatrolRecordRoute::getInspectionRecordId, patrolInspectionRecordList.get(0).getId())
+                    .eq(PatrolRecordRoute::getInspectionContentId,patrolRouteContentList.get(i).getInspectionContentId());
+            List<PatrolRecordRoute> patrolInspectionSchemeList = patrolRecordRouteService.list(queryWrapper);
+
+            PatrolRouteContentListVo patrolRouteContentListVo = new PatrolRouteContentListVo();
+            patrolRouteContentListVo.setId(patrolRouteContentList.get(i).getId());
+            patrolRouteContentListVo.setInspectionRouteId(patrolRouteContentList.get(i).getInspectionRouteId());
+            patrolRouteContentListVo.setInspectionContentId(patrolRouteContentList.get(i).getInspectionContentId());
+            patrolRouteContentListVo.setInspectionContentName(patrolRouteContentList.get(i).getInspectionContentName());
+            patrolRouteContentListVo.setInspectionDeviceName(patrolRouteContentList.get(i).getInspectionDeviceName());
+            patrolRouteContentListVo.setCreator(patrolRouteContentList.get(i).getCreator());
+            patrolRouteContentListVo.setCreateTime(patrolRouteContentList.get(i).getCreateTime());
+            patrolRouteContentListVo.setStatus(patrolRouteContentList.get(i).getStatus());
+            patrolRouteContentListVo.setPatrolRecordRoute(patrolInspectionSchemeList);
+            List inspectionDeviceAbnormalList = new ArrayList();
+            for (int j = 0;j<patrolInspectionSchemeList.size();j++){
+                inspectionDeviceAbnormalList.add(patrolInspectionSchemeList.get(j).getStatus());
+            }
+            if (inspectionDeviceAbnormalList.contains(2)){
+                inspectionDeviceAbnormalCount=inspectionDeviceAbnormalCount+1;
+            }
+            patrolRouteContentListVoList.add(patrolRouteContentListVo);
+        }
+
+        List<PatrolInspectionRecordDetailsVo> list = new ArrayList<>();
+        list.add(PatrolInspectionRecordDetailsVo.builder()
+                .id(patrolInspectionRecordList.get(0).getId())
+                .inspectionSchemeName(patrolInspectionRecordList.get(0).getInspectionSchemeName())
+                .inspectionNumber(patrolInspectionRecordList.get(0).getInspectionNumber())
+                .status(patrolInspectionRecordList.get(0).getStatus())
+                .createTime(patrolInspectionRecordList.get(0).getCreateTime())
+                .executionTime(patrolInspectionRecordList.get(0).getExecutionTime())
+                .inspectionDeviceCount(patrolRouteContentList.size())
+                .completionTime(patrolInspectionRecordList.get(0).getCompletionTime())
+                .siteName(patrolInspectionRecordList.get(0).getSiteName())
+                .creator(patrolInspectionRecordList.get(0).getCreator())
+                .inspectorsName(PatrolInspectorsList.get(0).getInspectorsName())
+                .inspectionRouteName(patrolInspectionRecordList.get(0).getInspectionRouteName())
+                .inspectionDeviceAbnormalCount(inspectionDeviceAbnormalCount)
+                .inspectionDeviceDefectCount(0)
+                .siteCount(1)
+                .inspectorsId(PatrolInspectorsList.get(0).getId())
+                .patrolRouteContentListVo(patrolRouteContentListVoList)
+                .build()
+        );
+
+        return list;
+    }
+}

+ 20 - 0
fiveep-service/src/main/java/com/bizmatics/service/impl/PatrolRecordRouteServiceImpl.java

@@ -0,0 +1,20 @@
+package com.bizmatics.service.impl;
+
+import com.bizmatics.model.PatrolRecordRoute;
+import com.bizmatics.persistence.mapper.PatrolRecordRouteMapper;
+import com.bizmatics.service.PatrolRecordRouteService;
+import com.bizmatics.common.mvc.base.AbstractCrudService;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author ya
+ * @since 2021-10-20
+ */
+@Service
+public class PatrolRecordRouteServiceImpl extends AbstractCrudService<PatrolRecordRouteMapper, PatrolRecordRoute> implements PatrolRecordRouteService {
+
+}