浏览代码

巡检管理-巡检内容相关接口上传

jichaobo 3 年之前
父节点
当前提交
44827b9133
共有 16 个文件被更改,包括 839 次插入0 次删除
  1. 21 0
      fiveep-controller/src/main/java/com/bizmatics/controller/web/PatrolContentEntryController.java
  2. 110 0
      fiveep-controller/src/main/java/com/bizmatics/controller/web/PatrolInspectionContentController.java
  3. 70 0
      fiveep-model/src/main/java/com/bizmatics/model/PatrolContentEntry.java
  4. 60 0
      fiveep-model/src/main/java/com/bizmatics/model/PatrolInspectionContent.java
  5. 67 0
      fiveep-model/src/main/java/com/bizmatics/model/vo/PatrolInspectionContentListVo.java
  6. 59 0
      fiveep-model/src/main/java/com/bizmatics/model/vo/PatrolInspectionContentOneVo.java
  7. 37 0
      fiveep-model/src/main/java/com/bizmatics/model/vo/PatrolInspectionContentVo.java
  8. 27 0
      fiveep-model/src/main/java/com/bizmatics/model/vo/SiteDeviceCountVo.java
  9. 16 0
      fiveep-persistence/src/main/java/com/bizmatics/persistence/mapper/PatrolContentEntryMapper.java
  10. 26 0
      fiveep-persistence/src/main/java/com/bizmatics/persistence/mapper/PatrolInspectionContentMapper.java
  11. 17 0
      fiveep-persistence/src/main/resources/mapper/mysql/PatrolContentEntryMapper.xml
  12. 72 0
      fiveep-persistence/src/main/resources/mapper/mysql/PatrolInspectionContentMapper.xml
  13. 16 0
      fiveep-service/src/main/java/com/bizmatics/service/PatrolContentEntryService.java
  14. 34 0
      fiveep-service/src/main/java/com/bizmatics/service/PatrolInspectionContentService.java
  15. 20 0
      fiveep-service/src/main/java/com/bizmatics/service/impl/PatrolContentEntryServiceImpl.java
  16. 187 0
      fiveep-service/src/main/java/com/bizmatics/service/impl/PatrolInspectionContentServiceImpl.java

+ 21 - 0
fiveep-controller/src/main/java/com/bizmatics/controller/web/PatrolContentEntryController.java

@@ -0,0 +1,21 @@
+package com.bizmatics.controller.web;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.stereotype.Controller;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author ya
+ * @since 2021-10-16
+ */
+@Controller
+@RequestMapping("/patrolContentEntry")
+public class PatrolContentEntryController {
+
+}
+

+ 110 - 0
fiveep-controller/src/main/java/com/bizmatics/controller/web/PatrolInspectionContentController.java

@@ -0,0 +1,110 @@
+package com.bizmatics.controller.web;
+
+
+import com.bizmatics.common.core.bean.ApiResult;
+import com.bizmatics.model.PatrolContentEntry;
+import com.bizmatics.model.vo.PatrolInspectionContentListVo;
+import com.bizmatics.model.vo.PatrolInspectionContentVo;
+import com.bizmatics.model.vo.SiteDeviceCountVo;
+import com.bizmatics.service.PatrolInspectionContentService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 前端控制器
+ * </p>
+ *
+ * @author ya
+ * @since 2021-10-16
+ */
+@RestController
+@RequestMapping("/patrolInspectionContent")
+public class PatrolInspectionContentController {
+
+    @Autowired
+    private PatrolInspectionContentService patrolInspectionContentService;
+
+    /**
+     * 巡检管理-巡检内容-新增
+     * @param patrolInspectionContentVo
+     * @return
+     */
+    @GetMapping("patrolInspectionContentAdd")
+    public ApiResult<Void> patrolInspectionContentAdd(@RequestBody PatrolInspectionContentVo patrolInspectionContentVo
+    ) {
+        patrolInspectionContentService.patrolInspectionContentAdd(patrolInspectionContentVo);
+        return ApiResult.success();
+    }
+
+    /**
+     * 巡检管理-巡检内容-修改
+     * @param patrolInspectionContentVo
+     * @return
+     */
+    @GetMapping("patrolInspectionContentUpdate")
+    public ApiResult<Void> patrolInspectionContentUpdate(@RequestBody PatrolInspectionContentVo patrolInspectionContentVo
+    ) {
+        patrolInspectionContentService.patrolInspectionContentUpdate(patrolInspectionContentVo);
+        return ApiResult.success();
+    }
+
+    /**
+     * 巡检管理-巡检内容-注销
+     * @param id 巡检内容id
+     * @return
+     */
+    @GetMapping("patrolInspectionContentDel")
+    public ApiResult<Void> patrolInspectionContentDel(@RequestParam Integer id
+    ) {
+        patrolInspectionContentService.patrolInspectionContentDel(id);
+        return ApiResult.success();
+    }
+
+    /**
+     * 巡检管理-巡检内容-巡检设备列表
+     * @param inspectionContentName
+     * @return
+     */
+    @GetMapping("patrolInspectionContentList")
+    public ApiResult<List<PatrolInspectionContentListVo>> patrolInspectionContentList(@RequestParam(required = false) String inspectionContentName
+    ) {
+        return ApiResult.success(patrolInspectionContentService.patrolInspectionContentList(inspectionContentName));
+    }
+
+    /**
+     * 巡检管理-巡检内容-巡检内容查看详情与回显
+     * @param id  巡检内容ID
+     * @return
+     */
+    @GetMapping("patrolInspectionContentDetailsList")
+    public ApiResult<List<PatrolInspectionContentListVo>> patrolInspectionContentDetailsList(@RequestParam Integer id
+    ) {
+        return ApiResult.success(patrolInspectionContentService.patrolInspectionContentDetailsList(id));
+    }
+
+    /**
+     * 巡检管理-巡检内容-巡检内容检查项查询
+     * @param id 巡检内容ID
+     * @return
+     */
+    @GetMapping("patrolContentEntryList")
+    public ApiResult<List<PatrolContentEntry>> patrolContentEntryList(@RequestParam Integer id
+    ) {
+        return ApiResult.success(patrolInspectionContentService.patrolContentEntryList(id));
+    }
+
+    /**
+     *巡检管理-巡检内容-左侧站点目录
+     * @param siteName 站点名称
+     * @return
+     */
+    @GetMapping("patrolInspectionContentSiteList")
+    public ApiResult<List<SiteDeviceCountVo>> patrolInspectionContentSiteList(@RequestParam(required = false) String siteName
+    ) {
+        return ApiResult.success(patrolInspectionContentService.patrolInspectionContentSiteList(siteName));
+    }
+}
+

+ 70 - 0
fiveep-model/src/main/java/com/bizmatics/model/PatrolContentEntry.java

@@ -0,0 +1,70 @@
+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-16
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class PatrolContentEntry implements Serializable {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 巡检内容检查项id
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 巡检内容id
+     */
+    private Integer inspectionContentId;
+
+    /**
+     * 巡检设备id
+     */
+    private Integer inspectionDeviceId;
+
+    /**
+     * 检查条目检查项id
+     */
+    private Integer checkEntryId;
+
+    /**
+     * 参考值
+     */
+    private String referenceValue;
+
+    /**
+     * 创建人
+     */
+    private String creator;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    /**
+     * 启用状态(0 未启用,1 启用)
+     */
+    private Integer status;
+
+
+}

+ 60 - 0
fiveep-model/src/main/java/com/bizmatics/model/PatrolInspectionContent.java

@@ -0,0 +1,60 @@
+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-16
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class PatrolInspectionContent implements Serializable {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 巡检内容id
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 巡检内容名称
+     */
+    private String inspectionContentName;
+
+    /**
+     * 巡检设备id(1,2,3,4,5,6)
+     */
+    private Integer inspectionDeviceId;
+
+    /**
+     * 创建人
+     */
+    private String creator;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    /**
+     * 启用状态(0 未启用,1 启用)
+     */
+    private Integer status;
+
+
+}

+ 67 - 0
fiveep-model/src/main/java/com/bizmatics/model/vo/PatrolInspectionContentListVo.java

@@ -0,0 +1,67 @@
+package com.bizmatics.model.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.bizmatics.model.PatrolContentEntry;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author ya
+ * @since 2021-10-16
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class PatrolInspectionContentListVo implements Serializable {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 巡检内容id
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 巡检内容名称
+     */
+    private String inspectionContentName;
+
+    /**
+     * 巡检设备id(1,2,3,4,5,6)
+     */
+    private Integer inspectionDeviceId;
+
+    /**
+     * 创建人
+     */
+    private String creator;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    /**
+     * 启用状态(0 未启用,1 启用)
+     */
+    private Integer status;
+
+    private String deviceTypeName;
+
+    private Integer deviceTypeId;
+
+    private String inspectionDeviceName;
+
+    private List<PatrolContentEntry> patrolContentEntry;
+}

+ 59 - 0
fiveep-model/src/main/java/com/bizmatics/model/vo/PatrolInspectionContentOneVo.java

@@ -0,0 +1,59 @@
+package com.bizmatics.model.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+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-16
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class PatrolInspectionContentOneVo implements Serializable {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 巡检内容id
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 巡检内容名称
+     */
+    private String inspectionContentName;
+
+    /**
+     * 巡检设备id(1,2,3,4,5,6)
+     */
+    private String inspectionDeviceId;
+
+    /**
+     * 创建人
+     */
+    private String creator;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    /**
+     * 启用状态(0 未启用,1 启用)
+     */
+    private Integer status;
+
+
+}

+ 37 - 0
fiveep-model/src/main/java/com/bizmatics/model/vo/PatrolInspectionContentVo.java

@@ -0,0 +1,37 @@
+package com.bizmatics.model.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.bizmatics.model.DeviceAnalogVariableList;
+import com.bizmatics.model.PatrolCheckEntry;
+import com.bizmatics.model.PatrolContentEntry;
+import com.bizmatics.model.PatrolInspectionContent;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author ya
+ * @since 2021-10-16
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class PatrolInspectionContentVo {
+    /**
+     * 巡检内容检查项
+     */
+    private List<PatrolCheckEntry> patrolCheckEntry;
+
+    private PatrolInspectionContentOneVo patrolInspectionContentOneVo;
+
+
+}

+ 27 - 0
fiveep-model/src/main/java/com/bizmatics/model/vo/SiteDeviceCountVo.java

@@ -0,0 +1,27 @@
+package com.bizmatics.model.vo;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ *
+ * </p>
+ *
+ * @author ya
+ * @since 2021-10-16
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class SiteDeviceCountVo {
+
+    private Integer id;
+
+    private String siteName;
+
+    private Integer deviceCount;
+
+
+}

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

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

+ 26 - 0
fiveep-persistence/src/main/java/com/bizmatics/persistence/mapper/PatrolInspectionContentMapper.java

@@ -0,0 +1,26 @@
+package com.bizmatics.persistence.mapper;
+
+import com.bizmatics.common.mvc.base.CrudMapper;
+import com.bizmatics.model.PatrolInspectionContent;
+import com.bizmatics.model.vo.PatrolInspectionContentListVo;
+import com.bizmatics.model.vo.SiteDeviceCountVo;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * <p>
+ * Mapper 接口
+ * </p>
+ *
+ * @author ya
+ * @since 2021-10-16
+ */
+public interface PatrolInspectionContentMapper extends CrudMapper<PatrolInspectionContent> {
+    List<PatrolInspectionContentListVo> patrolInspectionContentList(@Param("inspectionContentName") String inspectionContentName,
+                                                                    @Param("id") Integer id,
+                                                                    @Param("siteId") Integer siteId);
+
+    List<SiteDeviceCountVo> patrolInspectionContentSiteList(@Param("siteName") String siteName,
+                                                            @Param("userId") Integer userId);
+}

+ 17 - 0
fiveep-persistence/src/main/resources/mapper/mysql/PatrolContentEntryMapper.xml

@@ -0,0 +1,17 @@
+<?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.PatrolContentEntryMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.bizmatics.model.PatrolContentEntry">
+        <id column="id" property="id" />
+        <result column="inspection_content_id" property="inspectionContentId" />
+        <result column="inspection_device_id" property="inspectionDeviceId" />
+        <result column="check_entry_id" property="checkEntryId" />
+        <result column="reference_value" property="referenceValue" />
+        <result column="creator" property="creator" />
+        <result column="create_time" property="createTime" />
+        <result column="status" property="status" />
+    </resultMap>
+
+</mapper>

+ 72 - 0
fiveep-persistence/src/main/resources/mapper/mysql/PatrolInspectionContentMapper.xml

@@ -0,0 +1,72 @@
+<?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.PatrolInspectionContentMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.bizmatics.model.PatrolInspectionContent">
+        <id column="id" property="id" />
+        <result column="inspection_content_name" property="inspectionContentName" />
+        <result column="inspection_device_id" property="inspectionDeviceId" />
+        <result column="creator" property="creator" />
+        <result column="create_time" property="createTime" />
+        <result column="status" property="status" />
+    </resultMap>
+    <select id="patrolInspectionContentList" resultType="com.bizmatics.model.vo.PatrolInspectionContentListVo">
+        SELECT
+        a.*, c.device_type_name,b.device_type_id,b.inspection_device_name
+        FROM
+        patrol_inspection_content AS a
+        JOIN patrol_inspection_device AS b ON a.inspection_device_id = b.id
+        JOIN patrol_device_type AS c ON b.device_type_id=c.id
+        <where>
+            a.status =1
+            <if test="inspectionContentName != null and inspectionContentName !=''">
+                and a.inspection_content_name LIKE CONCAT(CONCAT('%', #{inspectionContentName}), '%')
+            </if>
+            <if test="id != null and id !=0">
+                and a.id = #{id}
+            </if>
+            <if test="siteId != null and siteId !=0">
+                and b.site_id = #{siteId}
+            </if>
+        </where>
+        order by a.id desc
+    </select>
+
+    <select id="patrolInspectionContentSiteList" resultType="com.bizmatics.model.vo.SiteDeviceCountVo">
+        SELECT
+        b.id,
+        b.site_name,
+
+        IF (
+        c.device_count &lt;&gt; '',
+        c.device_count,
+        0
+        ) AS device_count
+        FROM
+        user_site AS a
+        JOIN site AS b ON a.site_id = b.id
+        LEFT JOIN (
+        SELECT
+        s.id,
+        s.site_name,
+        COUNT(o.id) AS device_count
+        FROM
+        site AS s
+        JOIN patrol_inspection_device AS o ON s.id = o.site_id
+        GROUP BY
+        s.id
+        ) AS c ON b.id = c.id
+        <where>
+            b. enable = 1
+            <if test="userId != null and userId != 0">
+                and a.user_id = #{userId}
+            </if>
+            <if test="siteName != null and siteName !=''">
+                and b.site_name LIKE CONCAT(CONCAT('%', #{siteName}), '%')
+            </if>
+        </where>
+        order by b.id desc
+    </select>
+
+</mapper>

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

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

+ 34 - 0
fiveep-service/src/main/java/com/bizmatics/service/PatrolInspectionContentService.java

@@ -0,0 +1,34 @@
+package com.bizmatics.service;
+
+import com.bizmatics.model.PatrolContentEntry;
+import com.bizmatics.model.PatrolInspectionContent;
+import com.bizmatics.common.mvc.base.CrudService;
+import com.bizmatics.model.vo.PatrolInspectionContentListVo;
+import com.bizmatics.model.vo.PatrolInspectionContentVo;
+import com.bizmatics.model.vo.SiteDeviceCountVo;
+
+import java.util.List;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author ya
+ * @since 2021-10-16
+ */
+public interface PatrolInspectionContentService extends CrudService<PatrolInspectionContent> {
+    void patrolInspectionContentAdd(PatrolInspectionContentVo patrolInspectionContentVo);
+
+    void patrolInspectionContentUpdate(PatrolInspectionContentVo patrolInspectionContentVo);
+
+    void patrolInspectionContentDel(Integer id);
+
+    List<PatrolInspectionContentListVo> patrolInspectionContentList(String inspectionContentName);
+
+    List<PatrolInspectionContentListVo> patrolInspectionContentDetailsList(Integer id);
+
+    List<PatrolContentEntry> patrolContentEntryList(Integer id);
+
+    List<SiteDeviceCountVo> patrolInspectionContentSiteList(String siteName);
+}

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

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

+ 187 - 0
fiveep-service/src/main/java/com/bizmatics/service/impl/PatrolInspectionContentServiceImpl.java

@@ -0,0 +1,187 @@
+package com.bizmatics.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.bizmatics.common.mvc.base.AbstractCrudService;
+import com.bizmatics.model.PatrolCheckEntry;
+import com.bizmatics.model.PatrolContentEntry;
+import com.bizmatics.model.PatrolInspectionContent;
+import com.bizmatics.model.PatrolInspectionDevice;
+import com.bizmatics.model.system.SysUser;
+import com.bizmatics.model.vo.PatrolInspectionContentListVo;
+import com.bizmatics.model.vo.PatrolInspectionContentOneVo;
+import com.bizmatics.model.vo.PatrolInspectionContentVo;
+import com.bizmatics.model.vo.SiteDeviceCountVo;
+import com.bizmatics.persistence.mapper.PatrolInspectionContentMapper;
+import com.bizmatics.service.PatrolContentEntryService;
+import com.bizmatics.service.PatrolInspectionContentService;
+import com.bizmatics.service.util.SecurityUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * <p>
+ * 服务实现类
+ * </p>
+ *
+ * @author ya
+ * @since 2021-10-16
+ */
+@Service
+public class PatrolInspectionContentServiceImpl extends AbstractCrudService<PatrolInspectionContentMapper, PatrolInspectionContent> implements PatrolInspectionContentService {
+    @Autowired
+    private PatrolContentEntryService patrolContentEntryService;
+
+    @Override
+    public void patrolInspectionContentAdd(PatrolInspectionContentVo patrolInspectionContentVo) {
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        PatrolInspectionContentOneVo patrolInspectionContentOneVo = patrolInspectionContentVo.getPatrolInspectionContentOneVo();
+        String inspectionDeviceIdArr[] = patrolInspectionContentOneVo.getInspectionDeviceId().split(",");
+        PatrolInspectionContent patrolInspectionContent = new PatrolInspectionContent();
+        patrolInspectionContent.setInspectionContentName(patrolInspectionContentOneVo.getInspectionContentName());
+        patrolInspectionContent.setCreator(user.getUserName());
+        patrolInspectionContent.setCreateTime(new Date());
+        patrolInspectionContent.setStatus(1);
+        List<PatrolCheckEntry> patrolCheckEntry = patrolInspectionContentVo.getPatrolCheckEntry();
+        PatrolContentEntry patrolContentEntry = new PatrolContentEntry();
+        for (int i = 0; i < inspectionDeviceIdArr.length; i++) {
+            patrolInspectionContent.setInspectionDeviceId(Integer.parseInt(inspectionDeviceIdArr[i]));
+            this.save(patrolInspectionContent);
+            int inspectionContentId = patrolInspectionContent.getId();
+            for (int j = 0; j < patrolCheckEntry.size(); j++) {
+                patrolContentEntry.setInspectionContentId(inspectionContentId);
+                patrolContentEntry.setCheckEntryId(patrolCheckEntry.get(j).getId());
+                patrolContentEntry.setStatus(1);
+                patrolContentEntry.setCreator(user.getUserName());
+                patrolContentEntry.setCreateTime(new Date());
+                patrolContentEntry.setReferenceValue(patrolCheckEntry.get(j).getReferenceValue());
+                patrolContentEntry.setInspectionDeviceId(Integer.parseInt(inspectionDeviceIdArr[i]));
+                patrolContentEntryService.save(patrolContentEntry);
+            }
+
+        }
+    }
+
+    @Override
+    public void patrolInspectionContentUpdate(PatrolInspectionContentVo patrolInspectionContentVo) {
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        PatrolInspectionContent patrolInspectionContent = new PatrolInspectionContent();
+        patrolInspectionContent.setInspectionContentName(patrolInspectionContentVo.getPatrolInspectionContentOneVo().getInspectionContentName());
+        int inspectionDeviceId = Integer.parseInt(patrolInspectionContentVo.getPatrolInspectionContentOneVo().getInspectionDeviceId());
+        patrolInspectionContent.setInspectionDeviceId(inspectionDeviceId);
+        patrolInspectionContent.setId(patrolInspectionContentVo.getPatrolInspectionContentOneVo().getId());
+        this.updateById(patrolInspectionContent);
+
+        //旧数据
+        LambdaQueryWrapper<PatrolContentEntry> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.eq(PatrolContentEntry::getInspectionContentId, patrolInspectionContent.getId())
+                .eq(PatrolContentEntry::getInspectionDeviceId, patrolInspectionContent.getInspectionDeviceId());
+        List<PatrolContentEntry> patrolContentEntryList = patrolContentEntryService.list(queryWrapper);
+        if (patrolContentEntryList.size()>0){
+            for (int i = 0;i<patrolContentEntryList.size();i++){
+                PatrolContentEntry patrolContentEntry = new PatrolContentEntry();
+                patrolContentEntry.setStatus(0);
+                patrolContentEntry.setId(patrolContentEntryList.get(i).getId());
+                patrolContentEntryService.updateById(patrolContentEntry);
+            }
+        }
+
+        if (patrolInspectionContentVo.getPatrolCheckEntry().size()>0){
+            for (int i = 0; i < patrolInspectionContentVo.getPatrolCheckEntry().size(); i++){
+                PatrolContentEntry patrolContentEntry = new PatrolContentEntry();
+                patrolContentEntry.setInspectionContentId(patrolInspectionContent.getId());
+                patrolContentEntry.setInspectionDeviceId(patrolInspectionContent.getInspectionDeviceId());
+                patrolContentEntry.setCheckEntryId(patrolInspectionContentVo.getPatrolCheckEntry().get(i).getId());
+                patrolContentEntry.setReferenceValue(patrolInspectionContentVo.getPatrolCheckEntry().get(i).getReferenceValue());
+                patrolContentEntry.setCreator(user.getUserName());
+                patrolContentEntry.setStatus(1);
+                patrolContentEntry.setCreateTime(new Date());
+                patrolContentEntryService.save(patrolContentEntry);
+            }
+        }
+
+//        List<Integer> list = new ArrayList<Integer>();
+//        for (int j = 0; j < patrolContentEntryList.size(); j++) {
+//            for (int i = 0; i < patrolInspectionContentVo.getPatrolCheckEntry().size(); i++) {
+//                if (patrolContentEntryList.get(j).getCheckEntryId() != patrolInspectionContentVo.getPatrolCheckEntry().get(i).getId()) {
+//                    if (!list.contains(patrolInspectionContentVo.getPatrolCheckEntry().get(i).getId())) {
+//                        PatrolContentEntry patrolContentEntry = new PatrolContentEntry();
+//                        patrolContentEntry.setInspectionContentId(patrolInspectionContent.getId());
+//                        patrolContentEntry.setInspectionDeviceId(patrolInspectionContent.getInspectionDeviceId());
+//                        patrolContentEntry.setCheckEntryId(patrolInspectionContentVo.getPatrolCheckEntry().get(i).getId());
+//                        patrolContentEntry.setReferenceValue(patrolInspectionContentVo.getPatrolCheckEntry().get(i).getReferenceValue());
+//                        patrolContentEntry.setCreator(user.getUserName());
+//                        patrolContentEntry.setStatus(1);
+//                        patrolContentEntry.setCreateTime(new Date());
+//                        patrolContentEntryService.save(patrolContentEntry);
+//                        list.add(patrolInspectionContentVo.getPatrolCheckEntry().get(i).getId());
+//                    }
+//                }
+//            }
+//        }
+//
+//        LambdaQueryWrapper<PatrolContentEntry> queryWrapperOne = Wrappers.lambdaQuery();
+//        queryWrapperOne.eq(PatrolContentEntry::getInspectionContentId, patrolInspectionContent.getId())
+//                .eq(PatrolContentEntry::getInspectionDeviceId, patrolInspectionContent.getInspectionDeviceId());
+//        List<PatrolContentEntry> patrolContentEntryListOne = patrolContentEntryService.list(queryWrapperOne);
+//
+//        for (int i = 0; i < patrolInspectionContentVo.getPatrolCheckEntry().size(); i++) {
+//            for (int j = 0; j < patrolContentEntryListOne.size(); j++) {
+//                PatrolContentEntry patrolContentEntry = new PatrolContentEntry();
+//                patrolContentEntry.setId(patrolContentEntryListOne.get(j).getId());
+//                if (patrolInspectionContentVo.getPatrolCheckEntry().get(i).getId() != patrolContentEntryListOne.get(j).getCheckEntryId()) {
+//                    patrolContentEntry.setStatus(0);
+//                } else {
+//                    patrolContentEntry.setStatus(1);
+//                }
+//                patrolContentEntryService.updateById(patrolContentEntry);
+//            }
+//        }
+    }
+
+    @Override
+    public void patrolInspectionContentDel(Integer id) {
+        PatrolInspectionContent patrolInspectionContent = new PatrolInspectionContent();
+        patrolInspectionContent.setId(id);
+        patrolInspectionContent.setStatus(0);
+        this.updateById(patrolInspectionContent);
+    }
+
+    @Override
+    public List<PatrolInspectionContentListVo> patrolInspectionContentList(String inspectionContentName) {
+        List<PatrolInspectionContentListVo> list = baseMapper.patrolInspectionContentList(inspectionContentName, 0, 0);
+        return list;
+    }
+
+    @Override
+    public List<PatrolInspectionContentListVo> patrolInspectionContentDetailsList(Integer id) {
+        List<PatrolInspectionContentListVo> list = baseMapper.patrolInspectionContentList(null, id, 0);
+        LambdaQueryWrapper<PatrolContentEntry> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.eq(PatrolContentEntry::getStatus, 1)
+                .eq(PatrolContentEntry::getInspectionContentId, id);
+        List<PatrolContentEntry> patrolContentEntryListOne = patrolContentEntryService.list(queryWrapper);
+        list.get(0).setPatrolContentEntry(patrolContentEntryListOne);
+        return list;
+    }
+
+    @Override
+    public List<PatrolContentEntry> patrolContentEntryList(Integer id){
+        LambdaQueryWrapper<PatrolContentEntry> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.eq(PatrolContentEntry::getStatus, 1)
+                .eq(PatrolContentEntry::getInspectionContentId, id);
+        List<PatrolContentEntry> patrolContentEntryListOne = patrolContentEntryService.list(queryWrapper);
+        return patrolContentEntryListOne;
+    }
+
+    @Override
+    public List<SiteDeviceCountVo> patrolInspectionContentSiteList(String siteName){
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        Integer userId = user.getUserId().intValue();
+        List<SiteDeviceCountVo> list = baseMapper.patrolInspectionContentSiteList(siteName, userId);
+        return list;
+    }
+}