Browse Source

巡检记录模块相关接口开发

jichaobo 2 years ago
parent
commit
13ebc576df
23 changed files with 1152 additions and 30 deletions
  1. 1 1
      service-fire/service-fire-biz/src/main/java/com/usky/fire/controller/MybatisGeneratorUtils.java
  2. 80 0
      service-fire/service-fire-biz/src/main/java/com/usky/fire/controller/web/PatrolInspectionRecordController.java
  3. 123 0
      service-fire/service-fire-biz/src/main/java/com/usky/fire/domain/PatrolInspectionRecord.java
  4. 44 0
      service-fire/service-fire-biz/src/main/java/com/usky/fire/domain/PatrolInspectionRecordOption.java
  5. 42 0
      service-fire/service-fire-biz/src/main/java/com/usky/fire/domain/PatrolInspectionRecordPicture.java
  6. 16 0
      service-fire/service-fire-biz/src/main/java/com/usky/fire/mapper/PatrolInspectionRecordMapper.java
  7. 16 0
      service-fire/service-fire-biz/src/main/java/com/usky/fire/mapper/PatrolInspectionRecordOptionMapper.java
  8. 16 0
      service-fire/service-fire-biz/src/main/java/com/usky/fire/mapper/PatrolInspectionRecordPictureMapper.java
  9. 16 0
      service-fire/service-fire-biz/src/main/java/com/usky/fire/service/PatrolInspectionRecordOptionService.java
  10. 16 0
      service-fire/service-fire-biz/src/main/java/com/usky/fire/service/PatrolInspectionRecordPictureService.java
  11. 38 0
      service-fire/service-fire-biz/src/main/java/com/usky/fire/service/PatrolInspectionRecordService.java
  12. 54 29
      service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionPlanServiceImpl.java
  13. 20 0
      service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionRecordOptionServiceImpl.java
  14. 20 0
      service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionRecordPictureServiceImpl.java
  15. 279 0
      service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionRecordServiceImpl.java
  16. 46 0
      service-fire/service-fire-biz/src/main/java/com/usky/fire/service/util/OnlineMethod.java
  17. 69 0
      service-fire/service-fire-biz/src/main/java/com/usky/fire/service/vo/ContentOptionVo.java
  18. 10 0
      service-fire/service-fire-biz/src/main/java/com/usky/fire/service/vo/PatrolInspectionContentVo.java
  19. 135 0
      service-fire/service-fire-biz/src/main/java/com/usky/fire/service/vo/PatrolInspectionRecordVo.java
  20. 58 0
      service-fire/service-fire-biz/src/main/java/com/usky/fire/service/vo/RecordStatisticsVo.java
  21. 28 0
      service-fire/service-fire-biz/src/main/resources/mapper.fire/PatrolInspectionRecordMapper.xml
  22. 13 0
      service-fire/service-fire-biz/src/main/resources/mapper.fire/PatrolInspectionRecordOptionMapper.xml
  23. 12 0
      service-fire/service-fire-biz/src/main/resources/mapper.fire/PatrolInspectionRecordPictureMapper.xml

+ 1 - 1
service-fire/service-fire-biz/src/main/java/com/usky/fire/controller/MybatisGeneratorUtils.java

@@ -71,7 +71,7 @@ public class MybatisGeneratorUtils {
         // strategy.setTablePrefix("t_"); // 表名前缀
         // strategy.setTablePrefix("t_"); // 表名前缀
         strategy.setEntityLombokModel(true); //使用lombok
         strategy.setEntityLombokModel(true); //使用lombok
         //修改自己想要生成的表
         //修改自己想要生成的表
-        strategy.setInclude("special_rest_day");  // 逆向工程使用的表   如果要生成多个,这里可以传入String[]
+        strategy.setInclude("patrol_inspection_record");  // 逆向工程使用的表   如果要生成多个,这里可以传入String[]
         mpg.setStrategy(strategy);
         mpg.setStrategy(strategy);
 
 
         // 关闭默认 xml 生成,调整生成 至 根目录
         // 关闭默认 xml 生成,调整生成 至 根目录

+ 80 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/controller/web/PatrolInspectionRecordController.java

@@ -0,0 +1,80 @@
+package com.usky.fire.controller.web;
+
+
+import com.usky.common.core.bean.ApiResult;
+import com.usky.common.core.bean.CommonPage;
+import com.usky.fire.domain.PatrolInspectionRecord;
+import com.usky.fire.service.PatrolInspectionRecordService;
+import com.usky.fire.service.vo.PatrolInspectionRecordVo;
+import com.usky.fire.service.vo.RecordStatisticsVo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * 巡查自检-巡检记录
+ *
+ * @author JCB
+ * @since 2022-07-21
+ */
+@RestController
+@RequestMapping("/patrolInspectionRecord")
+public class PatrolInspectionRecordController {
+
+    @Autowired
+    private PatrolInspectionRecordService patrolInspectionRecordService;
+
+    /**
+     * 巡查自检-巡检记录-列表查询
+     *
+     * @param areaName      区域名称
+     * @param siteName      地点名称
+     * @param name          人员名称
+     * @param planType      计划类型
+     * @param startDateTime 开始时间
+     * @param endDateTime   结束时间
+     * @param pageNum       当前页
+     * @param pageSize      每页条数
+     * @return
+     */
+    @GetMapping("patrolInspectionRecordLsit")
+    public ApiResult<CommonPage<PatrolInspectionRecord>> patrolInspectionRecordLsit(@RequestParam(value = "areaName", required = false) String areaName,
+                                                                                    @RequestParam(value = "siteName", required = false) String siteName,
+                                                                                    @RequestParam(value = "name", required = false) String name,
+                                                                                    @RequestParam(value = "planType", required = false) Integer planType,
+                                                                                    @RequestParam(value = "startDateTime", required = false) String startDateTime,
+                                                                                    @RequestParam(value = "endDateTime", required = false) String endDateTime,
+                                                                                    @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
+                                                                                    @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) {
+        return ApiResult.success(patrolInspectionRecordService.patrolInspectionRecordLsit(areaName, siteName, name, planType, startDateTime, endDateTime, pageNum, pageSize));
+    }
+
+    /**
+     * 巡查自检-巡检记录-详情查询
+     *
+     * @param id 记录ID
+     * @return
+     */
+    @GetMapping("patrolInspectionRecordDetails")
+    public ApiResult<List<PatrolInspectionRecordVo>> patrolInspectionRecordDetails(@RequestParam(value = "id") Integer id) {
+        return ApiResult.success(patrolInspectionRecordService.patrolInspectionRecordDetails(id));
+    }
+
+    /**
+     * 巡查自检-巡检记录-巡检情况统计
+     *
+     * @param startDate 开始日期
+     * @param endDate   结束日期
+     * @return
+     */
+    @GetMapping("recordStatistics")
+    public ApiResult<RecordStatisticsVo> recordStatistics(@RequestParam(value = "startDate") String startDate,
+                                                          @RequestParam(value = "endDate") String endDate) {
+        return ApiResult.success(patrolInspectionRecordService.recordStatistics(startDate, endDate));
+    }
+}
+

+ 123 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/domain/PatrolInspectionRecord.java

@@ -0,0 +1,123 @@
+package com.usky.fire.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.time.LocalDateTime;
+import java.io.Serializable;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 巡检记录表
+ * </p>
+ *
+ * @author JCB
+ * @since 2022-07-21
+ */
+@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;
+
+    /**
+     * 地点号码
+     */
+    private String siteNubmber;
+
+    /**
+     * 地点类型
+     */
+    private Integer siteType;
+
+    /**
+     * 区域名称
+     */
+    private String areaName;
+
+    /**
+     * 地点名称
+     */
+    private String siteName;
+
+    /**
+     * 巡检人员
+     */
+    private String name;
+
+    /**
+     * 联系电话
+     */
+    private String phone;
+
+    /**
+     * 计划类型(1 普通计划,2 按次计划)
+     */
+    private Integer planType;
+
+    /**
+     * 定位 (0:未定位 1:已定位)
+     */
+    private Integer siteStatus;
+
+    /**
+     * 经度
+     */
+    private String longitude;
+
+    /**
+     * 纬度
+     */
+    private String latitude;
+
+    /**
+     * 开始时间
+     */
+    private LocalDateTime startDate;
+
+    /**
+     * 结束时间
+     */
+    private LocalDateTime endDate;
+
+    /**
+     * 创建时间/巡检时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 巡检计划主表ID
+     */
+    private Integer planId;
+
+    /**
+     * 巡检计划子表ID
+     */
+    private Integer planSonId;
+
+    /**
+     * 巡检地点ID
+     */
+    private Integer siteId;
+
+    /**
+     * 租户ID
+     */
+    private Integer tenantId;
+
+    /**
+     * 单位ID
+     */
+    private Integer companyId;
+
+
+}

+ 44 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/domain/PatrolInspectionRecordOption.java

@@ -0,0 +1,44 @@
+package com.usky.fire.domain;
+
+import java.io.Serializable;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 巡检记录内容选项关联表
+ * </p>
+ *
+ * @author JCB
+ * @since 2022-07-21
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class PatrolInspectionRecordOption implements Serializable {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 巡检记录内容选项关联表主键ID
+     */
+    private Integer id;
+
+    /**
+     * 记录ID
+     */
+    private Integer recordId;
+
+    /**
+     * 内容选项ID
+     */
+    private Integer contentOptionId;
+
+    /**
+     * 备注
+     */
+    private String remarks;
+
+
+}

+ 42 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/domain/PatrolInspectionRecordPicture.java

@@ -0,0 +1,42 @@
+package com.usky.fire.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.io.Serializable;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 记录上传图片关联表
+ * </p>
+ *
+ * @author JCB
+ * @since 2022-07-21
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class PatrolInspectionRecordPicture implements Serializable {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 记录上传图片关联表主键ID
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 巡检记录ID
+     */
+    private Integer recordId;
+
+    /**
+     * 图片路径
+     */
+    private String pictureUrl;
+
+
+}

+ 16 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/mapper/PatrolInspectionRecordMapper.java

@@ -0,0 +1,16 @@
+package com.usky.fire.mapper;
+
+import com.usky.fire.domain.PatrolInspectionRecord;
+import com.usky.common.mybatis.core.CrudMapper;
+
+/**
+ * <p>
+ * 巡检记录表 Mapper 接口
+ * </p>
+ *
+ * @author JCB
+ * @since 2022-07-21
+ */
+public interface PatrolInspectionRecordMapper extends CrudMapper<PatrolInspectionRecord> {
+
+}

+ 16 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/mapper/PatrolInspectionRecordOptionMapper.java

@@ -0,0 +1,16 @@
+package com.usky.fire.mapper;
+
+import com.usky.fire.domain.PatrolInspectionRecordOption;
+import com.usky.common.mybatis.core.CrudMapper;
+
+/**
+ * <p>
+ * 巡检记录内容选项关联表 Mapper 接口
+ * </p>
+ *
+ * @author JCB
+ * @since 2022-07-21
+ */
+public interface PatrolInspectionRecordOptionMapper extends CrudMapper<PatrolInspectionRecordOption> {
+
+}

+ 16 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/mapper/PatrolInspectionRecordPictureMapper.java

@@ -0,0 +1,16 @@
+package com.usky.fire.mapper;
+
+import com.usky.fire.domain.PatrolInspectionRecordPicture;
+import com.usky.common.mybatis.core.CrudMapper;
+
+/**
+ * <p>
+ * 记录上传图片关联表 Mapper 接口
+ * </p>
+ *
+ * @author JCB
+ * @since 2022-07-21
+ */
+public interface PatrolInspectionRecordPictureMapper extends CrudMapper<PatrolInspectionRecordPicture> {
+
+}

+ 16 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/PatrolInspectionRecordOptionService.java

@@ -0,0 +1,16 @@
+package com.usky.fire.service;
+
+import com.usky.fire.domain.PatrolInspectionRecordOption;
+import com.usky.common.mybatis.core.CrudService;
+
+/**
+ * <p>
+ * 巡检记录内容选项关联表 服务类
+ * </p>
+ *
+ * @author JCB
+ * @since 2022-07-21
+ */
+public interface PatrolInspectionRecordOptionService extends CrudService<PatrolInspectionRecordOption> {
+
+}

+ 16 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/PatrolInspectionRecordPictureService.java

@@ -0,0 +1,16 @@
+package com.usky.fire.service;
+
+import com.usky.fire.domain.PatrolInspectionRecordPicture;
+import com.usky.common.mybatis.core.CrudService;
+
+/**
+ * <p>
+ * 记录上传图片关联表 服务类
+ * </p>
+ *
+ * @author JCB
+ * @since 2022-07-21
+ */
+public interface PatrolInspectionRecordPictureService extends CrudService<PatrolInspectionRecordPicture> {
+
+}

+ 38 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/PatrolInspectionRecordService.java

@@ -0,0 +1,38 @@
+package com.usky.fire.service;
+
+import com.usky.common.core.bean.CommonPage;
+import com.usky.fire.domain.PatrolInspectionRecord;
+import com.usky.common.mybatis.core.CrudService;
+import com.usky.fire.service.vo.PatrolInspectionRecordVo;
+import com.usky.fire.service.vo.RecordStatisticsVo;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 巡检记录表 服务类
+ * </p>
+ *
+ * @author JCB
+ * @since 2022-07-21
+ */
+public interface PatrolInspectionRecordService extends CrudService<PatrolInspectionRecord> {
+
+    CommonPage<PatrolInspectionRecord> patrolInspectionRecordLsit(String areaName,
+                                                                  String siteName,
+                                                                  String name,
+                                                                  Integer planType,
+                                                                  String startDateTime,
+                                                                  String endDateTime,
+                                                                  Integer pageNum,
+                                                                  Integer pageSize);
+
+    List<PatrolInspectionRecordVo> patrolInspectionRecordDetails(Integer id);
+
+
+    List<Integer> getPlanSon(String startDate, String endDate);
+
+    Integer getPlanSiteSonCount(List<Integer> planSonidList, Integer inspectionStatus);
+
+    RecordStatisticsVo recordStatistics(String startDate, String endDate);
+}

+ 54 - 29
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionPlanServiceImpl.java

@@ -3,6 +3,7 @@ package com.usky.fire.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.usky.common.core.bean.CommonPage;
 import com.usky.common.core.bean.CommonPage;
+import com.usky.common.core.exception.BusinessException;
 import com.usky.common.mybatis.core.AbstractCrudService;
 import com.usky.common.mybatis.core.AbstractCrudService;
 import com.usky.common.security.utils.SecurityUtils;
 import com.usky.common.security.utils.SecurityUtils;
 import com.usky.fire.domain.*;
 import com.usky.fire.domain.*;
@@ -56,6 +57,9 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
     @Autowired
     @Autowired
     private PatrolInspectionSiteService patrolInspectionSiteService;
     private PatrolInspectionSiteService patrolInspectionSiteService;
 
 
+    @Autowired
+    private PatrolInspectionRecordService patrolInspectionRecordService;
+
     @Override
     @Override
     public List<PatrolInspectionAreaVo> planLeftList() {
     public List<PatrolInspectionAreaVo> planLeftList() {
         LambdaQueryWrapper<PatrolInspectionArea> queryWrapper = Wrappers.lambdaQuery();
         LambdaQueryWrapper<PatrolInspectionArea> queryWrapper = Wrappers.lambdaQuery();
@@ -107,6 +111,19 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
     @Override
     @Override
     @Transactional
     @Transactional
     public void addPatrolInspectionPlan(PatrolInspectionPlanVo patrolInspectionPlanVo) {
     public void addPatrolInspectionPlan(PatrolInspectionPlanVo patrolInspectionPlanVo) {
+        Integer planCycle = patrolInspectionPlanVo.getPlanCycle();
+        String timeStr = patrolInspectionPlanVo.getStartDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+        Date startDate = OnlineMethod.getDate(timeStr);
+        LocalDate ss = null;
+        if (planCycle == 1) {
+            ss = OnlineMethod.getDate(timeStr, "yyyy-MM-dd", true, 1 * patrolInspectionPlanVo.getWeekCount() - 1);
+        } else if (planCycle == 2) {
+            ss = OnlineMethod.getDate(timeStr, "yyyy-MM-dd", true, 7 * patrolInspectionPlanVo.getWeekCount() - 1);
+        } else if (planCycle == 3) {
+            ss = OnlineMethod.getMonthDate(startDate, 1 * patrolInspectionPlanVo.getWeekCount());
+        } else if (planCycle == 4) {
+            ss = OnlineMethod.getMonthDate(startDate, 12 * patrolInspectionPlanVo.getWeekCount());
+        }
         //主表数据添加
         //主表数据添加
         PatrolInspectionPlan patrolInspectionPlan = new PatrolInspectionPlan();
         PatrolInspectionPlan patrolInspectionPlan = new PatrolInspectionPlan();
         patrolInspectionPlan.setPlanName(patrolInspectionPlanVo.getPlanName());
         patrolInspectionPlan.setPlanName(patrolInspectionPlanVo.getPlanName());
@@ -114,8 +131,6 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
         if (patrolInspectionPlanVo.getPlanType() == 1) {
         if (patrolInspectionPlanVo.getPlanType() == 1) {
             patrolInspectionPlan.setEndDate(patrolInspectionPlanVo.getEndDate());
             patrolInspectionPlan.setEndDate(patrolInspectionPlanVo.getEndDate());
         } else {
         } else {
-            String timeStr = patrolInspectionPlanVo.getStartDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
-            LocalDate ss = OnlineMethod.getDate(timeStr, "yyyy-MM-dd", true, 7 * patrolInspectionPlanVo.getWeekCount());
             patrolInspectionPlan.setEndDate(ss);
             patrolInspectionPlan.setEndDate(ss);
         }
         }
         patrolInspectionPlan.setAreaId(patrolInspectionPlanVo.getAreaId());
         patrolInspectionPlan.setAreaId(patrolInspectionPlanVo.getAreaId());
@@ -157,7 +172,7 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
             days = OnlineMethod.fun(patrolInspectionPlanVo.getStartDate(), date);
             days = OnlineMethod.fun(patrolInspectionPlanVo.getStartDate(), date);
         }
         }
         for (int i = 0; i < days; i++) {
         for (int i = 0; i < days; i++) {
-            LocalDate date1 = OnlineMethod.getDate(timeStr3, "yyyy-MM-dd", true, i+1);
+            LocalDate date1 = OnlineMethod.getDate(timeStr3, "yyyy-MM-dd", true, i + 1);
             Date date = Date.from(date1.atStartOfDay(ZoneOffset.ofHours(8)).toInstant());
             Date date = Date.from(date1.atStartOfDay(ZoneOffset.ofHours(8)).toInstant());
             String week1 = OnlineMethod.getWeekOfDate(date);
             String week1 = OnlineMethod.getWeekOfDate(date);
             if (patrolInspectionPlanVo.getRestDay().contains(week1)) {
             if (patrolInspectionPlanVo.getRestDay().contains(week1)) {
@@ -174,7 +189,7 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
             String timeStr1 = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
             String timeStr1 = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
             for (int i = 0; i < day; i++) {
             for (int i = 0; i < day; i++) {
                 for (int j = 0; j < patrolInspectionPlanVo.getPlanScheduleList().size(); j++) {
                 for (int j = 0; j < patrolInspectionPlanVo.getPlanScheduleList().size(); j++) {
-                    LocalDate s = OnlineMethod.getDate(timeStr1, "yyyy-MM-dd", true, i+1);
+                    LocalDate s = OnlineMethod.getDate(timeStr1, "yyyy-MM-dd", true, i + 1);
                     Date date = Date.from(s.atStartOfDay(ZoneOffset.ofHours(8)).toInstant());
                     Date date = Date.from(s.atStartOfDay(ZoneOffset.ofHours(8)).toInstant());
                     String week = OnlineMethod.getWeekOfDate(date);
                     String week = OnlineMethod.getWeekOfDate(date);
                     if (!patrolInspectionPlanVo.getRestDay().contains(week)) {
                     if (!patrolInspectionPlanVo.getRestDay().contains(week)) {
@@ -210,18 +225,11 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
                 }
                 }
             }
             }
         } else {//按次计划
         } else {//按次计划
-            for (int i = 0; i < patrolInspectionPlanVo.getWeekCount(); i++) {
-                String timeStr2 = patrolInspectionPlanVo.getStartDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
-                LocalDate sss = OnlineMethod.getDate(timeStr2, "yyyy-MM-dd", true, 7 * (i + 1));
+            for (int i = 0; i < patrolInspectionPlanVo.getPlanFrequency(); i++) {
                 PatrolInspectionPlanSon patrolInspectionPlanSon = new PatrolInspectionPlanSon();
                 PatrolInspectionPlanSon patrolInspectionPlanSon = new PatrolInspectionPlanSon();
                 patrolInspectionPlanSon.setPlanId(fid);
                 patrolInspectionPlanSon.setPlanId(fid);
-                if (i == 0) {
-                    patrolInspectionPlanSon.setStartDate(patrolInspectionPlanVo.getStartDate());
-                } else {
-                    LocalDate ssss = OnlineMethod.getDate(timeStr2, "yyyy-MM-dd", true, 7 * i + 1);
-                    patrolInspectionPlanSon.setStartDate(ssss);
-                }
-                patrolInspectionPlanSon.setEndDate(sss);
+                patrolInspectionPlanSon.setStartDate(patrolInspectionPlanVo.getStartDate());
+                patrolInspectionPlanSon.setEndDate(ss);
                 patrolInspectionPlanSon.setPersonnelId(patrolInspectionPlanVo.getPlanScheduleList().get(0).getPersonnelId());
                 patrolInspectionPlanSon.setPersonnelId(patrolInspectionPlanVo.getPlanScheduleList().get(0).getPersonnelId());
                 patrolInspectionPlanSon.setAreaId(patrolInspectionPlanVo.getAreaId());
                 patrolInspectionPlanSon.setAreaId(patrolInspectionPlanVo.getAreaId());
                 patrolInspectionPlanSon.setPlanType(patrolInspectionPlanVo.getPlanType());
                 patrolInspectionPlanSon.setPlanType(patrolInspectionPlanVo.getPlanType());
@@ -254,6 +262,26 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
     @Override
     @Override
     @Transactional
     @Transactional
     public void updatePatrolInspectionPlan(PatrolInspectionPlanVo patrolInspectionPlanVo) {
     public void updatePatrolInspectionPlan(PatrolInspectionPlanVo patrolInspectionPlanVo) {
+        LambdaQueryWrapper<PatrolInspectionRecord> queryWrapperSix = Wrappers.lambdaQuery();
+        queryWrapperSix.eq(PatrolInspectionRecord::getPlanId, patrolInspectionPlanVo.getId());
+        List<PatrolInspectionRecord> patrolInspectionRecordList = patrolInspectionRecordService.list(queryWrapperSix);
+        if (patrolInspectionRecordList.size() <= 0) {
+            throw new BusinessException("巡检计划已执行中不可修改");
+        }
+        Integer planCycle = patrolInspectionPlanVo.getPlanCycle();
+        String timeStr = patrolInspectionPlanVo.getStartDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+        Date startDate = OnlineMethod.getDate(timeStr);
+        LocalDate ss = null;
+        if (planCycle == 1) {
+            ss = OnlineMethod.getDate(timeStr, "yyyy-MM-dd", true, 1 * patrolInspectionPlanVo.getWeekCount() - 1);
+        } else if (planCycle == 2) {
+            ss = OnlineMethod.getDate(timeStr, "yyyy-MM-dd", true, 7 * patrolInspectionPlanVo.getWeekCount() - 1);
+        } else if (planCycle == 3) {
+            ss = OnlineMethod.getMonthDate(startDate, 1 * patrolInspectionPlanVo.getWeekCount());
+        } else if (planCycle == 4) {
+            ss = OnlineMethod.getMonthDate(startDate, 12 * patrolInspectionPlanVo.getWeekCount());
+        }
+
         //主表数据修改
         //主表数据修改
         PatrolInspectionPlan patrolInspectionPlan = new PatrolInspectionPlan();
         PatrolInspectionPlan patrolInspectionPlan = new PatrolInspectionPlan();
         patrolInspectionPlan.setId(patrolInspectionPlanVo.getId());
         patrolInspectionPlan.setId(patrolInspectionPlanVo.getId());
@@ -262,8 +290,6 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
         if (patrolInspectionPlanVo.getPlanType() == 1) {
         if (patrolInspectionPlanVo.getPlanType() == 1) {
             patrolInspectionPlan.setEndDate(patrolInspectionPlanVo.getEndDate());
             patrolInspectionPlan.setEndDate(patrolInspectionPlanVo.getEndDate());
         } else {
         } else {
-            String timeStr = patrolInspectionPlanVo.getStartDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
-            LocalDate ss = OnlineMethod.getDate(timeStr, "yyyy-MM-dd", true, 7 * patrolInspectionPlanVo.getWeekCount());
             patrolInspectionPlan.setEndDate(ss);
             patrolInspectionPlan.setEndDate(ss);
         }
         }
         patrolInspectionPlan.setAreaId(patrolInspectionPlanVo.getAreaId());
         patrolInspectionPlan.setAreaId(patrolInspectionPlanVo.getAreaId());
@@ -318,7 +344,7 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
             days = OnlineMethod.fun(patrolInspectionPlanVo.getStartDate(), date);
             days = OnlineMethod.fun(patrolInspectionPlanVo.getStartDate(), date);
         }
         }
         for (int i = 0; i < days; i++) {
         for (int i = 0; i < days; i++) {
-            LocalDate date1 = OnlineMethod.getDate(timeStr3, "yyyy-MM-dd", true, i+1);
+            LocalDate date1 = OnlineMethod.getDate(timeStr3, "yyyy-MM-dd", true, i + 1);
             Date date = Date.from(date1.atStartOfDay(ZoneOffset.ofHours(8)).toInstant());
             Date date = Date.from(date1.atStartOfDay(ZoneOffset.ofHours(8)).toInstant());
             String week1 = OnlineMethod.getWeekOfDate(date);
             String week1 = OnlineMethod.getWeekOfDate(date);
             if (patrolInspectionPlanVo.getRestDay().contains(week1)) {
             if (patrolInspectionPlanVo.getRestDay().contains(week1)) {
@@ -348,7 +374,7 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
             String timeStr1 = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
             String timeStr1 = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
             for (int i = 0; i < day; i++) {
             for (int i = 0; i < day; i++) {
                 for (int j = 0; j < patrolInspectionPlanVo.getPlanScheduleList().size(); j++) {
                 for (int j = 0; j < patrolInspectionPlanVo.getPlanScheduleList().size(); j++) {
-                    LocalDate s = OnlineMethod.getDate(timeStr1, "yyyy-MM-dd", true, i+1);
+                    LocalDate s = OnlineMethod.getDate(timeStr1, "yyyy-MM-dd", true, i + 1);
                     Date date = Date.from(s.atStartOfDay(ZoneOffset.ofHours(8)).toInstant());
                     Date date = Date.from(s.atStartOfDay(ZoneOffset.ofHours(8)).toInstant());
                     String week = OnlineMethod.getWeekOfDate(date);
                     String week = OnlineMethod.getWeekOfDate(date);
                     if (!patrolInspectionPlanVo.getRestDay().contains(week)) {
                     if (!patrolInspectionPlanVo.getRestDay().contains(week)) {
@@ -384,18 +410,11 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
                 }
                 }
             }
             }
         } else {//按次计划
         } else {//按次计划
-            for (int i = 0; i < patrolInspectionPlanVo.getWeekCount(); i++) {
-                String timeStr2 = patrolInspectionPlanVo.getStartDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
-                LocalDate sss = OnlineMethod.getDate(timeStr2, "yyyy-MM-dd", true, 7 * (i + 1));
+            for (int i = 0; i < patrolInspectionPlanVo.getPlanFrequency(); i++) {
                 PatrolInspectionPlanSon patrolInspectionPlanSon = new PatrolInspectionPlanSon();
                 PatrolInspectionPlanSon patrolInspectionPlanSon = new PatrolInspectionPlanSon();
                 patrolInspectionPlanSon.setPlanId(patrolInspectionPlanVo.getId());
                 patrolInspectionPlanSon.setPlanId(patrolInspectionPlanVo.getId());
-                if (i == 0) {
-                    patrolInspectionPlanSon.setStartDate(patrolInspectionPlanVo.getStartDate());
-                } else {
-                    LocalDate ssss = OnlineMethod.getDate(timeStr2, "yyyy-MM-dd", true, 7 * i + 1);
-                    patrolInspectionPlanSon.setStartDate(ssss);
-                }
-                patrolInspectionPlanSon.setEndDate(sss);
+                patrolInspectionPlanSon.setStartDate(patrolInspectionPlanVo.getStartDate());
+                patrolInspectionPlanSon.setEndDate(ss);
                 patrolInspectionPlanSon.setPersonnelId(patrolInspectionPlanVo.getPlanScheduleList().get(0).getPersonnelId());
                 patrolInspectionPlanSon.setPersonnelId(patrolInspectionPlanVo.getPlanScheduleList().get(0).getPersonnelId());
                 patrolInspectionPlanSon.setAreaId(patrolInspectionPlanVo.getAreaId());
                 patrolInspectionPlanSon.setAreaId(patrolInspectionPlanVo.getAreaId());
                 patrolInspectionPlanSon.setPlanType(patrolInspectionPlanVo.getPlanType());
                 patrolInspectionPlanSon.setPlanType(patrolInspectionPlanVo.getPlanType());
@@ -427,6 +446,12 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
     @Override
     @Override
     @Transactional
     @Transactional
     public void delPatrolInspectionPlan(Integer id) {
     public void delPatrolInspectionPlan(Integer id) {
+        LambdaQueryWrapper<PatrolInspectionRecord> queryWrapperSix = Wrappers.lambdaQuery();
+        queryWrapperSix.eq(PatrolInspectionRecord::getPlanId, id);
+        List<PatrolInspectionRecord> patrolInspectionRecordList = patrolInspectionRecordService.list(queryWrapperSix);
+        if (patrolInspectionRecordList.size() <= 0) {
+            throw new BusinessException("巡检计划已执行中不可删除");
+        }
         PatrolInspectionPlan patrolInspectionPlan = new PatrolInspectionPlan();
         PatrolInspectionPlan patrolInspectionPlan = new PatrolInspectionPlan();
         patrolInspectionPlan.setId(id);
         patrolInspectionPlan.setId(id);
         patrolInspectionPlan.setEnable(0);
         patrolInspectionPlan.setEnable(0);
@@ -535,7 +560,7 @@ public class PatrolInspectionPlanServiceImpl extends AbstractCrudService<PatrolI
             list1.add(patrolInspectionPlanDataVo);
             list1.add(patrolInspectionPlanDataVo);
         }
         }
         List<PatrolInspectionPlanDataVo> list3 = list1.stream().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
         List<PatrolInspectionPlanDataVo> list3 = list1.stream().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
-        return new CommonPage<>(list3, list1.size(), pageSize,pageNum);
+        return new CommonPage<>(list3, list1.size(), pageSize, pageNum);
     }
     }
 
 
 
 

+ 20 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionRecordOptionServiceImpl.java

@@ -0,0 +1,20 @@
+package com.usky.fire.service.impl;
+
+import com.usky.fire.domain.PatrolInspectionRecordOption;
+import com.usky.fire.mapper.PatrolInspectionRecordOptionMapper;
+import com.usky.fire.service.PatrolInspectionRecordOptionService;
+import com.usky.common.mybatis.core.AbstractCrudService;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 巡检记录内容选项关联表 服务实现类
+ * </p>
+ *
+ * @author JCB
+ * @since 2022-07-21
+ */
+@Service
+public class PatrolInspectionRecordOptionServiceImpl extends AbstractCrudService<PatrolInspectionRecordOptionMapper, PatrolInspectionRecordOption> implements PatrolInspectionRecordOptionService {
+
+}

+ 20 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionRecordPictureServiceImpl.java

@@ -0,0 +1,20 @@
+package com.usky.fire.service.impl;
+
+import com.usky.fire.domain.PatrolInspectionRecordPicture;
+import com.usky.fire.mapper.PatrolInspectionRecordPictureMapper;
+import com.usky.fire.service.PatrolInspectionRecordPictureService;
+import com.usky.common.mybatis.core.AbstractCrudService;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 记录上传图片关联表 服务实现类
+ * </p>
+ *
+ * @author JCB
+ * @since 2022-07-21
+ */
+@Service
+public class PatrolInspectionRecordPictureServiceImpl extends AbstractCrudService<PatrolInspectionRecordPictureMapper, PatrolInspectionRecordPicture> implements PatrolInspectionRecordPictureService {
+
+}

+ 279 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionRecordServiceImpl.java

@@ -0,0 +1,279 @@
+package com.usky.fire.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.usky.common.core.bean.CommonPage;
+import com.usky.common.mybatis.core.AbstractCrudService;
+import com.usky.common.security.utils.SecurityUtils;
+import com.usky.fire.domain.*;
+import com.usky.fire.mapper.PatrolInspectionRecordMapper;
+import com.usky.fire.service.*;
+import com.usky.fire.service.vo.ContentOptionVo;
+import com.usky.fire.service.vo.PatrolInspectionContentVo;
+import com.usky.fire.service.vo.PatrolInspectionRecordVo;
+import com.usky.fire.service.vo.RecordStatisticsVo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * <p>
+ * 巡检记录表 服务实现类
+ * </p>
+ *
+ * @author JCB
+ * @since 2022-07-21
+ */
+@Service
+public class PatrolInspectionRecordServiceImpl extends AbstractCrudService<PatrolInspectionRecordMapper, PatrolInspectionRecord> implements PatrolInspectionRecordService {
+
+    @Autowired
+    private PatrolInspectionRecordPictureService patrolInspectionRecordPictureService;
+
+    @Autowired
+    private PatrolInspectionRecordOptionService patrolInspectionRecordOptionService;
+
+    @Autowired
+    private SiteContentService siteContentService;
+
+    @Autowired
+    private PatrolInspectionContentService patrolInspectionContentService;
+
+    @Autowired
+    private ContentOptionService contentOptionService;
+
+    @Autowired
+    private PatrolInspectionPlanSonService patrolInspectionPlanSonService;
+
+    @Autowired
+    private PlanSiteSonService planSiteSonService;
+
+    public CommonPage<PatrolInspectionRecord> patrolInspectionRecordLsit(String areaName, String siteName, String name,
+                                                                         Integer planType, String startDateTime, String endDateTime,
+                                                                         Integer pageNum, Integer pageSize) {
+        LambdaQueryWrapper<PatrolInspectionRecord> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.eq(PatrolInspectionRecord::getTenantId, SecurityUtils.getTenantId());
+        if (areaName != null && "".equals(areaName)) {
+            queryWrapper.like(PatrolInspectionRecord::getAreaName, areaName);
+        }
+        if (siteName != null && "".equals(siteName)) {
+            queryWrapper.like(PatrolInspectionRecord::getSiteName, siteName);
+        }
+        if (name != null && "".equals(name)) {
+            queryWrapper.like(PatrolInspectionRecord::getName, name);
+        }
+        if (planType != null && planType != 0) {
+            queryWrapper.eq(PatrolInspectionRecord::getPlanType, planType);
+        }
+        if (startDateTime != null && "".equals(startDateTime) && endDateTime != null && "".equals(endDateTime)) {
+            queryWrapper.between(PatrolInspectionRecord::getCreateTime, startDateTime, endDateTime);
+        }
+        queryWrapper.orderByDesc(PatrolInspectionRecord::getId);
+        List<PatrolInspectionRecord> patrolInspectionRecordList = this.list(queryWrapper);
+        List<PatrolInspectionRecord> list = patrolInspectionRecordList.stream().skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
+        return new CommonPage<>(list, patrolInspectionRecordList.size(), pageSize, pageNum);
+    }
+
+    public List<PatrolInspectionRecordVo> patrolInspectionRecordDetails(Integer id) {
+        //记录查询
+        LambdaQueryWrapper<PatrolInspectionRecord> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.eq(PatrolInspectionRecord::getTenantId, SecurityUtils.getTenantId())
+                .eq(PatrolInspectionRecord::getId, id);
+        List<PatrolInspectionRecord> patrolInspectionRecordList = this.list(queryWrapper);
+
+        //上传图片查询
+        LambdaQueryWrapper<PatrolInspectionRecordPicture> queryWrapperOne = Wrappers.lambdaQuery();
+        queryWrapperOne.eq(PatrolInspectionRecordPicture::getRecordId, id);
+        List<PatrolInspectionRecordPicture> patrolInspectionRecordPictureList = patrolInspectionRecordPictureService.list(queryWrapperOne);
+
+        //内容选中项查询
+        LambdaQueryWrapper<PatrolInspectionRecordOption> queryWrapperTwo = Wrappers.lambdaQuery();
+        queryWrapperTwo.eq(PatrolInspectionRecordOption::getRecordId, id);
+        List<PatrolInspectionRecordOption> patrolInspectionRecordOptionList = patrolInspectionRecordOptionService.list(queryWrapperTwo);
+
+        //地点内容ID查询
+        LambdaQueryWrapper<SiteContent> queryWrapperThree = Wrappers.lambdaQuery();
+        queryWrapperThree.in(SiteContent::getSiteId, patrolInspectionRecordList.get(0).getSiteId());
+        List<SiteContent> siteContentList = siteContentService.list(queryWrapperThree);
+
+        //内容ID重组
+        List<Integer> contentIdList = new ArrayList<>();
+        for (int i = 0; i < siteContentList.size(); i++) {
+            contentIdList.add(siteContentList.get(i).getContentId());
+        }
+
+        //内容查询
+        LambdaQueryWrapper<PatrolInspectionContent> queryWrapperFour = Wrappers.lambdaQuery();
+        queryWrapperFour.in(PatrolInspectionContent::getId, contentIdList)
+                .eq(PatrolInspectionContent::getEnable, 1);
+        List<PatrolInspectionContent> patrolInspectionContentList = patrolInspectionContentService.list(queryWrapperFour);
+
+        //内容选择项查询
+        LambdaQueryWrapper<ContentOption> queryWrapperFive = Wrappers.lambdaQuery();
+        queryWrapperFive.in(ContentOption::getContentId, contentIdList)
+                .eq(ContentOption::getEnable, 1);
+        List<ContentOption> contentOptionList = contentOptionService.list(queryWrapperFive);
+
+        //重组内容选项
+        List<ContentOptionVo> contentOptionVoList = new ArrayList<>();
+        for (int i = 0; i < contentOptionList.size(); i++) {
+            ContentOptionVo contentOptionVo = new ContentOptionVo();
+            contentOptionVo.setId(contentOptionList.get(i).getId());
+            contentOptionVo.setContentId(contentOptionList.get(i).getContentId());
+            contentOptionVo.setOptionName(contentOptionList.get(i).getOptionName());
+            contentOptionVo.setEnable(contentOptionList.get(i).getEnable());
+            contentOptionVo.setCreator(contentOptionList.get(i).getCreator());
+            contentOptionVo.setCreateTime(contentOptionList.get(i).getCreateTime());
+            contentOptionVo.setSelectStatus(false);
+            for (int j = 0; j < patrolInspectionRecordOptionList.size(); j++) {
+                contentOptionVo.setRemarks(patrolInspectionRecordOptionList.get(j).getRemarks());
+                if (contentOptionList.get(i).getId() == patrolInspectionRecordOptionList.get(j).getContentOptionId()) {
+                    contentOptionVo.setSelectStatus(true);
+                }
+            }
+            contentOptionVoList.add(contentOptionVo);
+        }
+
+        //重组内容
+        List<PatrolInspectionContentVo> patrolInspectionContentVoList = new ArrayList<>();
+        for (int i = 0; i < patrolInspectionContentList.size(); i++) {
+            PatrolInspectionContentVo patrolInspectionContentVo = new PatrolInspectionContentVo();
+            patrolInspectionContentVo.setId(patrolInspectionContentList.get(i).getId());
+            patrolInspectionContentVo.setContentTitle(patrolInspectionContentList.get(i).getContentTitle());
+            patrolInspectionContentVo.setContentDescribe(patrolInspectionContentList.get(i).getContentDescribe());
+            patrolInspectionContentVo.setSubmissionMethod(patrolInspectionContentList.get(i).getSubmissionMethod());
+            patrolInspectionContentVo.setTenantId(patrolInspectionContentList.get(i).getTenantId());
+            patrolInspectionContentVo.setCreateTime(patrolInspectionContentList.get(i).getCreateTime());
+            patrolInspectionContentVo.setCreator(patrolInspectionContentList.get(i).getCreator());
+            patrolInspectionContentVo.setEnable(patrolInspectionContentList.get(i).getEnable());
+            patrolInspectionContentVo.setCompanyId(patrolInspectionContentList.get(i).getCompanyId());
+            List<ContentOptionVo> contentOptionVoListOne = new ArrayList<>();
+            for (int j = 0; j < contentOptionVoList.size(); j++) {
+                if (patrolInspectionContentList.get(i).getId() == contentOptionVoList.get(j).getContentId()) {
+                    patrolInspectionContentVo.setRemarks(contentOptionVoList.get(j).getRemarks());
+                    contentOptionVoListOne.add(contentOptionVoList.get(j));
+                }
+            }
+            patrolInspectionContentVo.setContentOptionVoList(contentOptionVoListOne);
+            patrolInspectionContentVoList.add(patrolInspectionContentVo);
+        }
+
+        //重组巡检记录
+        List<PatrolInspectionRecordVo> list = new ArrayList<>();
+        for (int i = 0; i < patrolInspectionRecordList.size(); i++) {
+            PatrolInspectionRecordVo patrolInspectionRecordVo = new PatrolInspectionRecordVo();
+            patrolInspectionRecordVo.setId(patrolInspectionRecordList.get(i).getId());
+            patrolInspectionRecordVo.setSiteNubmber(patrolInspectionRecordList.get(i).getSiteNubmber());
+            patrolInspectionRecordVo.setSiteType(patrolInspectionRecordList.get(i).getSiteType());
+            patrolInspectionRecordVo.setAreaName(patrolInspectionRecordList.get(i).getAreaName());
+            patrolInspectionRecordVo.setSiteName(patrolInspectionRecordList.get(i).getSiteName());
+            patrolInspectionRecordVo.setName(patrolInspectionRecordList.get(i).getName());
+            patrolInspectionRecordVo.setPhone(patrolInspectionRecordList.get(i).getPhone());
+            patrolInspectionRecordVo.setPlanType(patrolInspectionRecordList.get(i).getPlanType());
+            patrolInspectionRecordVo.setSiteStatus(patrolInspectionRecordList.get(i).getSiteStatus());
+            patrolInspectionRecordVo.setLongitude(patrolInspectionRecordList.get(i).getLongitude());
+            patrolInspectionRecordVo.setLatitude(patrolInspectionRecordList.get(i).getLatitude());
+            patrolInspectionRecordVo.setStartDate(patrolInspectionRecordList.get(i).getStartDate());
+            patrolInspectionRecordVo.setEndDate(patrolInspectionRecordList.get(i).getEndDate());
+            patrolInspectionRecordVo.setCreateTime(patrolInspectionRecordList.get(i).getCreateTime());
+            patrolInspectionRecordVo.setPlanId(patrolInspectionRecordList.get(i).getPlanId());
+            patrolInspectionRecordVo.setPlanSonId(patrolInspectionRecordList.get(i).getPlanSonId());
+            patrolInspectionRecordVo.setSiteId(patrolInspectionRecordList.get(i).getSiteId());
+            patrolInspectionRecordVo.setTenantId(patrolInspectionRecordList.get(i).getTenantId());
+            patrolInspectionRecordVo.setCompanyId(patrolInspectionRecordList.get(i).getCompanyId());
+            patrolInspectionRecordVo.setRecordPictureList(patrolInspectionRecordPictureList);
+            patrolInspectionRecordVo.setContentVoList(patrolInspectionContentVoList);
+            list.add(patrolInspectionRecordVo);
+        }
+        return list;
+    }
+
+    @Override
+    public RecordStatisticsVo recordStatistics(String startDate, String endDate) {
+        List<Integer> planSonidListOne = this.getPlanSon(startDate, endDate);
+        Integer taskCount = 0;
+        Integer taskCountLeak = 0;
+        Integer taskCountComplete = 0;
+        Integer siteCount = 0;
+        Integer siteCountLeak = 0;
+        Integer planCount = 0;
+        if (planSonidListOne.size() > 0) {
+            planCount = planSonidListOne.size();
+            taskCount = this.getPlanSiteSonCount(planSonidListOne, 0);
+            taskCountLeak = this.getPlanSiteSonCount(planSonidListOne, 1);
+            taskCountComplete = this.getPlanSiteSonCount(planSonidListOne, 2);
+        }
+        List<Integer> planSonidListTwo = this.getPlanSon(null, null);
+        if (planSonidListTwo.size() > 0) {
+            siteCount = this.getPlanSiteSonCount(planSonidListOne, 0);
+            siteCountLeak = this.getPlanSiteSonCount(planSonidListOne, 1);
+        }
+        RecordStatisticsVo recordStatisticsVo = new RecordStatisticsVo();
+        recordStatisticsVo.setTaskCount(taskCount);
+        recordStatisticsVo.setTaskCountLeak(taskCountLeak);
+        recordStatisticsVo.setTaskCountComplete(taskCountComplete);
+        recordStatisticsVo.setSiteCount(siteCount);
+        recordStatisticsVo.setSiteCountLeak(siteCountLeak);
+        recordStatisticsVo.setPlanCount(planCount);
+        return recordStatisticsVo;
+    }
+
+    /**
+     * 子计划点位表总数统计
+     *
+     * @param planSonidList    子计划ID
+     * @param inspectionStatus 巡检状态(1 未巡检,2 已巡检)
+     * @return
+     */
+    @Override
+    public Integer getPlanSiteSonCount(List<Integer> planSonidList, Integer inspectionStatus) {
+        LambdaQueryWrapper<PlanSiteSon> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.in(PlanSiteSon::getPlanId, planSonidList);
+        if (inspectionStatus != 0 && inspectionStatus != null) {
+            queryWrapper.eq(PlanSiteSon::getInspectionStatus, inspectionStatus);
+        }
+        Integer taskCount = planSiteSonService.count(queryWrapper);
+        return taskCount;
+    }
+
+    /**
+     * 子计划数据查询
+     *
+     * @param startDate 开始时间 yyyy-MM-dd
+     * @param endDate   结束时间 yyyy-MM-dd
+     * @return
+     */
+    @Override
+    public List<Integer> getPlanSon(String startDate, String endDate) {
+        LambdaQueryWrapper<PatrolInspectionPlanSon> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.eq(PatrolInspectionPlanSon::getPlanType, 1)
+                .eq(PatrolInspectionPlanSon::getTenantId, SecurityUtils.getTenantId());
+        if (!"".equals(startDate) && startDate != null && !"".equals(endDate) && endDate != null) {
+            queryWrapper.between(PatrolInspectionPlanSon::getInspectionDate, startDate, endDate);
+        }
+
+        List<PatrolInspectionPlanSon> planCountListOne = patrolInspectionPlanSonService.list(queryWrapper);
+        List<Integer> planSonidListOne = new ArrayList<>();
+        for (int i = 0; i < planCountListOne.size(); i++) {
+            planSonidListOne.add(planCountListOne.get(i).getId());
+        }
+        LambdaQueryWrapper<PatrolInspectionPlanSon> queryWrapperOne = Wrappers.lambdaQuery();
+        queryWrapperOne.eq(PatrolInspectionPlanSon::getPlanType, 2)
+                .eq(PatrolInspectionPlanSon::getTenantId, SecurityUtils.getTenantId());
+        if (!"".equals(startDate) && startDate != null && !"".equals(endDate) && endDate != null) {
+            queryWrapperOne.and(wq -> wq
+                    .between(PatrolInspectionPlanSon::getStartDate, startDate, endDate)
+                    .or()
+                    .between(PatrolInspectionPlanSon::getEndDate, startDate, endDate)
+            ).groupBy(PatrolInspectionPlanSon::getId);
+        }
+        List<PatrolInspectionPlanSon> planCountListTwo = patrolInspectionPlanSonService.list(queryWrapperOne);
+        for (int i = 0; i < planCountListTwo.size(); i++) {
+            planSonidListOne.add(planCountListTwo.get(i).getId());
+        }
+        return planSonidListOne;
+    }
+}

+ 46 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/util/OnlineMethod.java

@@ -2,9 +2,13 @@ package com.usky.fire.service.util;
 
 
 import com.usky.fire.service.vo.PatrolInspectionAreaVo;
 import com.usky.fire.service.vo.PatrolInspectionAreaVo;
 
 
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.text.ParseException;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatter;
 import java.time.temporal.ChronoUnit;
 import java.time.temporal.ChronoUnit;
 import java.util.*;
 import java.util.*;
@@ -131,4 +135,46 @@ public class OnlineMethod {
         return weekDays[w];
         return weekDays[w];
     }
     }
 
 
+    /**
+     * 获取startDate日期后month月的日期
+     * @param startDate 开始日期
+     * @param month  几个月后
+     * @return
+     */
+    public static LocalDate getMonthDate(Date startDate,int month){
+        LocalDateTime localDateTime = startDate.toInstant()
+                .atZone(ZoneId.systemDefault() )
+                .toLocalDateTime().plusMonths(month);
+        LocalDate localDate = localDateTime.toLocalDate();
+//        Date date = Date.from(localDateTime.atZone( ZoneId.systemDefault()).toInstant());
+        return localDate;
+    }
+
+    /**
+     * String转Date
+     * @param timeStr 时间格式 yyyy-MM-dd
+     * @return
+     */
+    public static Date getDate(String timeStr){
+        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
+        Date date = null;
+        try {
+            date = df.parse(timeStr);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return date;
+    }
+
+
+    /**
+     * 保留2个小数
+     * @param value
+     * @return
+     */
+    public static String format1(double value) {
+        BigDecimal bd = new BigDecimal(value);
+        bd = bd.setScale(2, RoundingMode.HALF_UP);
+        return bd.toString();
+    }
 }
 }

+ 69 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/vo/ContentOptionVo.java

@@ -0,0 +1,69 @@
+package com.usky.fire.service.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.time.LocalDateTime;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author JCB
+ * @since 2022-07-15
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class ContentOptionVo implements Serializable {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 内容选项信息表ID
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 内容标题
+     */
+    private String optionName;
+
+    /**
+     * 内容ID
+     */
+    private Integer contentId;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 创建人
+     */
+    private String creator;
+
+    /**
+     * 使能标识(0 不生效,1 生效)
+     */
+    private Integer enable;
+
+    /**
+     * 是否勾选(true 选中 false 未选中)
+     */
+    private Boolean selectStatus;
+
+    /**
+     * 备注
+     */
+    private String remarks;
+
+
+}

+ 10 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/vo/PatrolInspectionContentVo.java

@@ -77,5 +77,15 @@ public class PatrolInspectionContentVo implements Serializable {
      */
      */
     private List<ContentOption> contentOptionList;
     private List<ContentOption> contentOptionList;
 
 
+    /**
+     * 选项内容
+     */
+    private List<ContentOptionVo> contentOptionVoList;
+
+    /**
+     * 备注
+     */
+    private String remarks;
+
 
 
 }
 }

+ 135 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/vo/PatrolInspectionRecordVo.java

@@ -0,0 +1,135 @@
+package com.usky.fire.service.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.usky.fire.domain.PatrolInspectionRecordPicture;
+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 JCB
+ * @since 2022-07-21
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class PatrolInspectionRecordVo implements Serializable {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 巡检记录表主键ID
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 地点号码
+     */
+    private String siteNubmber;
+
+    /**
+     * 地点类型
+     */
+    private Integer siteType;
+
+    /**
+     * 区域名称
+     */
+    private String areaName;
+
+    /**
+     * 地点名称
+     */
+    private String siteName;
+
+    /**
+     * 巡检人员
+     */
+    private String name;
+
+    /**
+     * 联系电话
+     */
+    private String phone;
+
+    /**
+     * 计划类型(1 普通计划,2 按次计划)
+     */
+    private Integer planType;
+
+    /**
+     * 定位 (0:未定位 1:已定位)
+     */
+    private Integer siteStatus;
+
+    /**
+     * 经度
+     */
+    private String longitude;
+
+    /**
+     * 纬度
+     */
+    private String latitude;
+
+    /**
+     * 开始时间
+     */
+    private LocalDateTime startDate;
+
+    /**
+     * 结束时间
+     */
+    private LocalDateTime endDate;
+
+    /**
+     * 创建时间/巡检时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 巡检计划主表ID
+     */
+    private Integer planId;
+
+    /**
+     * 巡检计划子表ID
+     */
+    private Integer planSonId;
+
+    /**
+     * 巡检地点ID
+     */
+    private Integer siteId;
+
+    /**
+     * 租户ID
+     */
+    private Integer tenantId;
+
+    /**
+     * 单位ID
+     */
+    private Integer companyId;
+
+    /**
+     * 图片路径
+     */
+    private List<PatrolInspectionRecordPicture> recordPictureList;
+
+    /**
+     * 内容数据
+     */
+    private List<PatrolInspectionContentVo> contentVoList;
+
+}

+ 58 - 0
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/vo/RecordStatisticsVo.java

@@ -0,0 +1,58 @@
+package com.usky.fire.service.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.time.LocalDateTime;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author JCB
+ * @since 2022-07-15
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class RecordStatisticsVo implements Serializable {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 点位巡检任务总数
+     */
+    private Integer taskCount;
+
+    /**
+     * 点位巡检完成数
+     */
+    private Integer taskCountLeak;
+
+    /**
+     * 点位漏检次数
+     */
+    private Integer taskCountComplete;
+
+    /**
+     * 累计点位巡检次数
+     */
+    private Integer siteCount;
+
+    /**
+     * 累计点位漏检次数
+     */
+    private Integer siteCountLeak;
+
+    /**
+     * 当前巡检计划数量
+     */
+    private Integer planCount;
+
+
+}

+ 28 - 0
service-fire/service-fire-biz/src/main/resources/mapper.fire/PatrolInspectionRecordMapper.xml

@@ -0,0 +1,28 @@
+<?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.usky.fire.mapper.PatrolInspectionRecordMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.usky.fire.domain.PatrolInspectionRecord">
+        <id column="id" property="id" />
+        <result column="site_nubmber" property="siteNubmber" />
+        <result column="site_type" property="siteType" />
+        <result column="area_name" property="areaName" />
+        <result column="site_name" property="siteName" />
+        <result column="name" property="name" />
+        <result column="phone" property="phone" />
+        <result column="plan_type" property="planType" />
+        <result column="site_status" property="siteStatus" />
+        <result column="longitude" property="longitude" />
+        <result column="latitude" property="latitude" />
+        <result column="start_date" property="startDate" />
+        <result column="end_date" property="endDate" />
+        <result column="create_time" property="createTime" />
+        <result column="plan_id" property="planId" />
+        <result column="plan_son_id" property="planSonId" />
+        <result column="site_id" property="siteId" />
+        <result column="tenant_id" property="tenantId" />
+        <result column="company_id" property="companyId" />
+    </resultMap>
+
+</mapper>

+ 13 - 0
service-fire/service-fire-biz/src/main/resources/mapper.fire/PatrolInspectionRecordOptionMapper.xml

@@ -0,0 +1,13 @@
+<?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.usky.fire.mapper.PatrolInspectionRecordOptionMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.usky.fire.domain.PatrolInspectionRecordOption">
+        <id column="id" property="id" />
+        <result column="record_id" property="recordId" />
+        <result column="content_option_id" property="contentOptionId" />
+        <result column="remarks" property="remarks" />
+    </resultMap>
+
+</mapper>

+ 12 - 0
service-fire/service-fire-biz/src/main/resources/mapper.fire/PatrolInspectionRecordPictureMapper.xml

@@ -0,0 +1,12 @@
+<?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.usky.fire.mapper.PatrolInspectionRecordPictureMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.usky.fire.domain.PatrolInspectionRecordPicture">
+        <id column="id" property="id" />
+        <result column="record_id" property="recordId" />
+        <result column="picture_url" property="pictureUrl" />
+    </resultMap>
+
+</mapper>