Browse Source

'优化定时同步巡检系统漏检数据到巡检异常记录表接口,添加日志记录,将抛错信息全部添加到日志记录中'

james 9 months ago
parent
commit
4ba0341812

+ 13 - 4
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionPlanSonServiceImpl.java

@@ -15,6 +15,8 @@ import com.usky.fire.mapper.PatrolInspectionRecordMapper;
 import com.usky.fire.service.*;
 import com.usky.fire.service.util.OnlineMethod;
 import com.usky.fire.service.vo.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -82,6 +84,8 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
     @Autowired
     private PatrolInspectionAbnormalService patrolInspectionAbnormalService;
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(PatrolInspectionPlanSonServiceImpl.class);
+
     @Override
     public Map<String, Object> appPlanStatistics(String currentDate) {
         Integer planSonCount = 0;
@@ -396,13 +400,14 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
 
     @Override
     public void addPatrolInspectionAbnormalData(){
+        LOGGER.info("巡检漏检定时任务 begin");
         DateTimeFormatter df1 = DateTimeFormatter.ofPattern("yyyy-MM-dd");
         String datetime1 = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
         String datetime2 = LocalDateTime.now().minusHours(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
 
         List<PatrolInspectionPlanSon> list = patrolInspectionPlanSonMapper.selectInspectionPlanSonData(datetime1,datetime2);
         if(list.size() <=0){
-            throw new BusinessException("当前时间向前一小时没有漏检记录");
+            LOGGER.info("当前时间向前一小时没有漏检记录");
         }
         List<Integer> sonIdlist = new ArrayList<>();
         for (int i = 0; i < list.size(); i++) {
@@ -420,12 +425,13 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
                 noSonIdList.add(siteSonList.get(i).getPlanId());
             }
             //获取巡检地点
+            LOGGER.info("获取巡检地点");
             LambdaQueryWrapper<PatrolInspectionSite> queryWrapper1 = Wrappers.lambdaQuery();
             queryWrapper1.in(PatrolInspectionSite::getId,siteIdList)
                     .eq(PatrolInspectionSite::getEnable,1);
             List<PatrolInspectionSite> siteList = patrolInspectionSiteService.list(queryWrapper1);
             if(siteList.size() <= 0){
-                throw new BusinessException("查询巡检地点记录为空");
+                LOGGER.info("查询巡检地点记录为空");
             }
             //获取巡检子计划
             LambdaQueryWrapper<PatrolInspectionPlanSon> planSonQueryWrapper = Wrappers.lambdaQuery();
@@ -443,12 +449,13 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
             //获取巡检计划
             List<PatrolInspectionPlan> noPlanIdList = patrolInspectionPlanMapper.selectNoPlanList(planIdList);
             //获取巡检人员
+            LOGGER.info("获取巡检人员");
             LambdaQueryWrapper<PatrolInspectionPersonnel> personnelQueryWrapper = Wrappers.lambdaQuery();
             personnelQueryWrapper.in(PatrolInspectionPersonnel::getId,personnelList)
                     .eq(PatrolInspectionPersonnel::getEnable,1);
             List<PatrolInspectionPersonnel> inspectionPersonnelList = patrolInspectionPersonnelService.list(personnelQueryWrapper);
             if(inspectionPersonnelList.size() <= 0){
-                throw new BusinessException("巡检人员信息不存在");
+                LOGGER.info("巡检人员信息不存在");
             }
             //获取巡检区域
             LambdaQueryWrapper<PatrolInspectionArea> queryWrapperOne = Wrappers.lambdaQuery();
@@ -456,7 +463,7 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
                     .eq(PatrolInspectionArea::getEnable,1);
             List<PatrolInspectionArea> areaInfoList = patrolInspectionAreaService.list(queryWrapperOne);
             if(areaInfoList.size() <= 0){
-                throw new BusinessException("巡检区域不存在");
+                LOGGER.info("巡检区域不存在");
             }
 
             for (int i = 0; i < siteSonList.size(); i++) {
@@ -529,6 +536,8 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
 
                 patrolInspectionAbnormalService.save(patrolInspectionAbnormal);
 
+                LOGGER.info("巡检漏检定时任务 end");
+
             }
 
         }