فهرست منبع

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

jichaobo 3 سال پیش
والد
کامیت
522be75e63

+ 1 - 1
fiveep-controller/src/main/java/com/bizmatics/controller/web/MybatisGeneratorUtils.java

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

+ 102 - 0
fiveep-model/src/main/java/com/bizmatics/model/vo/PatrolInspectionRecordDetailsVo.java

@@ -0,0 +1,102 @@
+package com.bizmatics.model.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.Builder;
+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-20
+ */
+@Builder
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class PatrolInspectionRecordDetailsVo{
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 巡检记录id
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 巡检计划名称
+     */
+    private String inspectionSchemeName;
+
+    /**
+     * 巡检次数
+     */
+    private Integer inspectionNumber;
+
+    /**
+     * 状态(0 未进行,1 进行中,2 已完成
+     */
+    private Integer status;
+
+    /**
+     * 巡检时间一
+     */
+    private Date createTime;
+
+    /**
+     * 巡检时间二
+     */
+    private String executionTime;
+
+    /**
+     * 巡检内容数量
+     */
+    private Integer inspectionDeviceCount;
+
+    /**
+     * 完成时间
+     */
+    private Date completionTime;
+
+    /**
+     * 站点名称
+     */
+    private String siteName;
+
+    /**
+     * 创建人
+     */
+    private String creator;
+
+    /**
+     * 责任人
+     */
+    private String inspectorsName;
+
+    /**
+     * 巡检线路名称
+     */
+    private String inspectionRouteName;
+
+    private Integer inspectionDeviceAbnormalCount;
+
+    private Integer inspectionDeviceDefectCount;
+
+    private Integer siteCount;
+
+    private Integer inspectorsId;
+
+    private List<PatrolRouteContentListVo> patrolRouteContentListVo;
+
+
+}

+ 101 - 0
fiveep-model/src/main/java/com/bizmatics/model/vo/PatrolInspectionRecordVo.java

@@ -0,0 +1,101 @@
+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-20
+ */
+@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;
+
+    /**
+     * 巡检计划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 String inspectionSchemeName;
+
+    private String teamName;
+
+    private String siteName;
+
+    private Integer inspectorsId;
+
+    private String executionTime;
+
+    private String inspectionRouteName;
+
+
+}

+ 68 - 0
fiveep-model/src/main/java/com/bizmatics/model/vo/PatrolRouteContentListVo.java

@@ -0,0 +1,68 @@
+package com.bizmatics.model.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.bizmatics.model.PatrolRecordRoute;
+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-19
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class PatrolRouteContentListVo implements Serializable {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 巡检路线与巡检内容关联id
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 巡检路线id
+     */
+    private Integer inspectionRouteId;
+
+    /**
+     * 巡检内容id
+     */
+    private Integer inspectionContentId;
+
+    /**
+     * 创建人
+     */
+    private String creator;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    /**
+     * 启用状态(0 未启用,1 启用)
+     */
+    private Integer status;
+
+    private String inspectionContentName;
+
+    private String inspectionDeviceName;
+
+
+    private List<PatrolRecordRoute> patrolRecordRoute;
+
+
+}

+ 66 - 0
fiveep-model/src/main/java/com/bizmatics/model/vo/PatrolRouteContentTimingVo.java

@@ -0,0 +1,66 @@
+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-19
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class PatrolRouteContentTimingVo implements Serializable {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 巡检内容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;
+
+
+    private String checkEntryName;
+
+
+}

+ 1 - 2
fiveep-service/src/main/java/com/bizmatics/service/impl/PatrolInspectionSchemeServiceImpl.java

@@ -14,6 +14,7 @@ import com.bizmatics.service.*;
 import com.bizmatics.service.util.SecurityUtils;
 import com.bizmatics.service.vo.CommonIcoVO;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
@@ -288,6 +289,4 @@ public class PatrolInspectionSchemeServiceImpl extends AbstractCrudService<Patro
         List<PatrolInspectionSchemeListVo> list = baseMapper.patrolInspectionSchemeList(id);
         return list;
     }
-
-
 }

+ 211 - 0
fiveep-service/src/main/java/com/bizmatics/service/job/PatrolTask.java

@@ -0,0 +1,211 @@
+package com.bizmatics.service.job;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.bizmatics.common.core.util.DateUtils;
+import com.bizmatics.model.PatrolInspectionRecord;
+import com.bizmatics.model.PatrolInspectionRoute;
+import com.bizmatics.model.PatrolInspectionScheme;
+import com.bizmatics.model.PatrolRecordRoute;
+import com.bizmatics.model.vo.PatrolRouteContentTimingVo;
+import com.bizmatics.persistence.mapper.PatrolInspectionRecordMapper;
+import com.bizmatics.service.PatrolInspectionRecordService;
+import com.bizmatics.service.PatrolInspectionRouteService;
+import com.bizmatics.service.PatrolInspectionSchemeService;
+import com.bizmatics.service.PatrolRecordRouteService;
+import com.bizmatics.service.es.RtAnalogService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Service;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author yq
+ * @date 2021/7/17 19:41
+ */
+@Slf4j
+@Service
+public class PatrolTask {
+
+    @Autowired
+    private PatrolInspectionSchemeService patrolInspectionSchemeService;
+
+    @Autowired
+    private PatrolInspectionRecordService patrolInspectionRecordService;
+    @Autowired
+    private PatrolInspectionRouteService patrolInspectionRouteService;
+    @Autowired
+    private PatrolInspectionRecordMapper patrolInspectionRecordMapper;
+    @Autowired
+    private PatrolRecordRouteService patrolRecordRouteService;
+
+    //每天凌晨0点执行一次
+//    @Scheduled(cron = "30 * * * * ?")
+    @Scheduled(cron = "0 0 0 * * ?")
+    public void PatrolInspectionRecordTiming() {
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+        SimpleDateFormat formatterOne = new SimpleDateFormat("dd");
+        SimpleDateFormat formatterTwo = new SimpleDateFormat("MM-dd");
+//        SysUser user = SecurityUtils.getLoginUser().getUser();
+        Date date = new Date();
+        String week = DateUtils.getWeek(date);
+        String datef = formatter.format(date);
+        String day = formatterOne.format(date);
+        String monthDay = formatterTwo.format(date);
+        log.info("巡检管理---" + datef + "巡检记录定时任务生成");
+//        log.info("addHadJob---startTime"+day);
+        LambdaQueryWrapper<PatrolInspectionScheme> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.lt(PatrolInspectionScheme::getSchemeStartDate, datef)
+                .gt(PatrolInspectionScheme::getSchemeEndDate, datef)
+                .eq(PatrolInspectionScheme::getStatus, 1);
+        List<PatrolInspectionScheme> patrolInspectionSchemeList = patrolInspectionSchemeService.list(queryWrapper);
+        if (patrolInspectionSchemeList.size() > 0) {
+            for (int i = 0; i < patrolInspectionSchemeList.size(); i++) {
+                PatrolInspectionRecord patrolInspectionRecord = new PatrolInspectionRecord();
+                patrolInspectionRecord.setInspectionSchemeId(patrolInspectionSchemeList.get(i).getId());
+                patrolInspectionRecord.setInspectionTeamId(patrolInspectionSchemeList.get(i).getInspectionTeamId());
+                patrolInspectionRecord.setInspectionSchedule(0.00);
+                patrolInspectionRecord.setCreateTime(new Date());
+                patrolInspectionRecord.setStatus(1);
+                if (patrolInspectionSchemeList.get(i).getInspectionCycleType() == 1) {
+                    LambdaQueryWrapper<PatrolInspectionRoute> queryWrapperTwo = Wrappers.lambdaQuery();
+                    queryWrapperTwo.eq(PatrolInspectionRoute::getStatus, 1).eq(PatrolInspectionRoute::getInspectionSchemeId, patrolInspectionSchemeList.get(i).getId());
+                    List<PatrolInspectionRoute> patrolInspectionRouteList = patrolInspectionRouteService.list(queryWrapperTwo);
+
+                    for (int j = 0; j < patrolInspectionRouteList.size(); j++) {
+                        patrolInspectionRecord.setInspectionNumber(patrolInspectionSchemeList.get(i).getExecutions() + 1);
+                        patrolInspectionRecord.setSiteId(patrolInspectionRouteList.get(j).getSiteId());
+                        patrolInspectionRecord.setInspectionRouteId(patrolInspectionRouteList.get(j).getId());
+                        patrolInspectionRecordService.save(patrolInspectionRecord);
+                        Integer inspectionRecordId = patrolInspectionRecord.getId();
+                        List<PatrolRouteContentTimingVo> patrolRouteContentTimingVoList = patrolInspectionRecordMapper.patrolRouteContentTimingVoList(patrolInspectionRouteList.get(j).getId());
+                        if (patrolRouteContentTimingVoList.size()>0){
+                            for (int k=0;k<patrolRouteContentTimingVoList.size();k++){
+                                PatrolRecordRoute patrolRecordRoute = new PatrolRecordRoute();
+                                patrolRecordRoute.setInspectionRecordId(inspectionRecordId);
+                                patrolRecordRoute.setInspectionRouteId(patrolInspectionRouteList.get(j).getId());
+                                patrolRecordRoute.setCreateTime(new Date());
+                                patrolRecordRoute.setInspectionSchemeId(patrolInspectionSchemeList.get(i).getId());
+                                patrolRecordRoute.setStatus(0);
+                                patrolRecordRoute.setCheckEntryName(patrolRouteContentTimingVoList.get(k).getCheckEntryName());
+                                patrolRecordRoute.setInspectionContentId(patrolRouteContentTimingVoList.get(k).getInspectionContentId());
+                                patrolRecordRouteService.save(patrolRecordRoute);
+
+                            }
+                        }
+
+                    }
+                    PatrolInspectionScheme patrolInspectionScheme = new PatrolInspectionScheme();
+                    patrolInspectionScheme.setId(patrolInspectionSchemeList.get(i).getId());
+                    patrolInspectionScheme.setExecutions(patrolInspectionSchemeList.get(i).getExecutions() + 1);
+                    patrolInspectionSchemeService.updateById(patrolInspectionScheme);
+
+                } else if (patrolInspectionSchemeList.get(i).getInspectionCycleType() == 2) {
+                    if (week.equals(patrolInspectionSchemeList.get(i).getExecutionTime())) {
+                        LambdaQueryWrapper<PatrolInspectionRoute> queryWrapperTwo = Wrappers.lambdaQuery();
+                        queryWrapperTwo.eq(PatrolInspectionRoute::getStatus, 1).eq(PatrolInspectionRoute::getInspectionSchemeId, patrolInspectionSchemeList.get(i).getId());
+                        List<PatrolInspectionRoute> patrolInspectionRouteList = patrolInspectionRouteService.list(queryWrapperTwo);
+
+                        for (int j = 0; j < patrolInspectionRouteList.size(); j++) {
+                            patrolInspectionRecord.setInspectionNumber(patrolInspectionSchemeList.get(i).getExecutions() + 1);
+                            patrolInspectionRecord.setSiteId(patrolInspectionRouteList.get(j).getSiteId());
+                            patrolInspectionRecord.setInspectionRouteId(patrolInspectionRouteList.get(j).getId());
+                            patrolInspectionRecordService.save(patrolInspectionRecord);
+                            Integer inspectionRecordId = patrolInspectionRecord.getId();
+                            List<PatrolRouteContentTimingVo> patrolRouteContentTimingVoList = patrolInspectionRecordMapper.patrolRouteContentTimingVoList(patrolInspectionRouteList.get(j).getId());
+                            if (patrolRouteContentTimingVoList.size()>0){
+                                for (int k=0;k<patrolRouteContentTimingVoList.size();k++){
+                                    PatrolRecordRoute patrolRecordRoute = new PatrolRecordRoute();
+                                    patrolRecordRoute.setInspectionRecordId(inspectionRecordId);
+                                    patrolRecordRoute.setInspectionRouteId(patrolInspectionRouteList.get(j).getId());
+                                    patrolRecordRoute.setCreateTime(new Date());
+                                    patrolRecordRoute.setInspectionSchemeId(patrolInspectionSchemeList.get(i).getId());
+                                    patrolRecordRoute.setStatus(0);
+                                    patrolRecordRoute.setCheckEntryName(patrolRouteContentTimingVoList.get(k).getCheckEntryName());
+                                    patrolRecordRoute.setInspectionContentId(patrolRouteContentTimingVoList.get(k).getInspectionContentId());
+                                    patrolRecordRouteService.save(patrolRecordRoute);
+
+                                }
+                            }
+                        }
+                        PatrolInspectionScheme patrolInspectionScheme = new PatrolInspectionScheme();
+                        patrolInspectionScheme.setId(patrolInspectionSchemeList.get(i).getId());
+                        patrolInspectionScheme.setExecutions(patrolInspectionSchemeList.get(i).getExecutions() + 1);
+                        patrolInspectionSchemeService.updateById(patrolInspectionScheme);
+                    }
+                } else if (patrolInspectionSchemeList.get(i).getInspectionCycleType() == 3) {
+                    if (day.equals(patrolInspectionSchemeList.get(i).getExecutionTime())) {
+                        LambdaQueryWrapper<PatrolInspectionRoute> queryWrapperTwo = Wrappers.lambdaQuery();
+                        queryWrapperTwo.eq(PatrolInspectionRoute::getStatus, 1).eq(PatrolInspectionRoute::getInspectionSchemeId, patrolInspectionSchemeList.get(i).getId());
+                        List<PatrolInspectionRoute> patrolInspectionRouteList = patrolInspectionRouteService.list(queryWrapperTwo);
+
+                        for (int j = 0; j < patrolInspectionRouteList.size(); j++) {
+                            patrolInspectionRecord.setInspectionNumber(patrolInspectionSchemeList.get(i).getExecutions() + 1);
+                            patrolInspectionRecord.setSiteId(patrolInspectionRouteList.get(j).getSiteId());
+                            patrolInspectionRecord.setInspectionRouteId(patrolInspectionRouteList.get(j).getId());
+                            patrolInspectionRecordService.save(patrolInspectionRecord);
+                            Integer inspectionRecordId = patrolInspectionRecord.getId();
+                            List<PatrolRouteContentTimingVo> patrolRouteContentTimingVoList = patrolInspectionRecordMapper.patrolRouteContentTimingVoList(patrolInspectionRouteList.get(j).getId());
+                            if (patrolRouteContentTimingVoList.size()>0){
+                                for (int k=0;k<patrolRouteContentTimingVoList.size();k++){
+                                    PatrolRecordRoute patrolRecordRoute = new PatrolRecordRoute();
+                                    patrolRecordRoute.setInspectionRecordId(inspectionRecordId);
+                                    patrolRecordRoute.setInspectionRouteId(patrolInspectionRouteList.get(j).getId());
+                                    patrolRecordRoute.setCreateTime(new Date());
+                                    patrolRecordRoute.setInspectionSchemeId(patrolInspectionSchemeList.get(i).getId());
+                                    patrolRecordRoute.setStatus(0);
+                                    patrolRecordRoute.setCheckEntryName(patrolRouteContentTimingVoList.get(k).getCheckEntryName());
+                                    patrolRecordRoute.setInspectionContentId(patrolRouteContentTimingVoList.get(k).getInspectionContentId());
+                                    patrolRecordRouteService.save(patrolRecordRoute);
+
+                                }
+                            }
+                        }
+                        PatrolInspectionScheme patrolInspectionScheme = new PatrolInspectionScheme();
+                        patrolInspectionScheme.setId(patrolInspectionSchemeList.get(i).getId());
+                        patrolInspectionScheme.setExecutions(patrolInspectionSchemeList.get(i).getExecutions() + 1);
+                        patrolInspectionSchemeService.updateById(patrolInspectionScheme);
+                    }
+                } else if (patrolInspectionSchemeList.get(i).getInspectionCycleType() == 4) {
+                    if (monthDay.equals(patrolInspectionSchemeList.get(i).getExecutionTime())) {
+                        LambdaQueryWrapper<PatrolInspectionRoute> queryWrapperTwo = Wrappers.lambdaQuery();
+                        queryWrapperTwo.eq(PatrolInspectionRoute::getStatus, 1).eq(PatrolInspectionRoute::getInspectionSchemeId, patrolInspectionSchemeList.get(i).getId());
+                        List<PatrolInspectionRoute> patrolInspectionRouteList = patrolInspectionRouteService.list(queryWrapperTwo);
+
+                        for (int j = 0; j < patrolInspectionRouteList.size(); j++) {
+                            patrolInspectionRecord.setInspectionNumber(patrolInspectionSchemeList.get(i).getExecutions() + 1);
+                            patrolInspectionRecord.setSiteId(patrolInspectionRouteList.get(j).getSiteId());
+                            patrolInspectionRecord.setInspectionRouteId(patrolInspectionRouteList.get(j).getId());
+                            patrolInspectionRecordService.save(patrolInspectionRecord);
+                            Integer inspectionRecordId = patrolInspectionRecord.getId();
+                            List<PatrolRouteContentTimingVo> patrolRouteContentTimingVoList = patrolInspectionRecordMapper.patrolRouteContentTimingVoList(patrolInspectionRouteList.get(j).getId());
+                            if (patrolRouteContentTimingVoList.size()>0){
+                                for (int k=0;k<patrolRouteContentTimingVoList.size();k++){
+                                    PatrolRecordRoute patrolRecordRoute = new PatrolRecordRoute();
+                                    patrolRecordRoute.setInspectionRecordId(inspectionRecordId);
+                                    patrolRecordRoute.setInspectionRouteId(patrolInspectionRouteList.get(j).getId());
+                                    patrolRecordRoute.setCreateTime(new Date());
+                                    patrolRecordRoute.setInspectionSchemeId(patrolInspectionSchemeList.get(i).getId());
+                                    patrolRecordRoute.setStatus(0);
+                                    patrolRecordRoute.setCheckEntryName(patrolRouteContentTimingVoList.get(k).getCheckEntryName());
+                                    patrolRecordRoute.setInspectionContentId(patrolRouteContentTimingVoList.get(k).getInspectionContentId());
+                                    patrolRecordRouteService.save(patrolRecordRoute);
+
+                                }
+                            }
+                        }
+                        PatrolInspectionScheme patrolInspectionScheme = new PatrolInspectionScheme();
+                        patrolInspectionScheme.setId(patrolInspectionSchemeList.get(i).getId());
+                        patrolInspectionScheme.setExecutions(patrolInspectionSchemeList.get(i).getExecutions() + 1);
+                        patrolInspectionSchemeService.updateById(patrolInspectionScheme);
+                    }
+                }
+            }
+        }
+        log.info("addHadJob---startTime" + datef);
+    }
+}