瀏覽代碼

连续正常天数逻辑修改

M墨鱼—_mo 5 年之前
父節點
當前提交
f827a4e4db

+ 30 - 6
web/src/main/java/com/jpsoft/smart/schduled/CheckPersonTask.java

@@ -49,18 +49,20 @@ public class CheckPersonTask {
         String recordTime = DateUtil.format(new Date(),"yyyy-MM-dd");
         List<CheckNumCompany> checkNumCompanyList = checkNumCompanyService.findByRecordTime(recordTime);
         List<TotalCheckCompany> totalCheckCompanyList = totalCheckCompanyService.findAll();
+        List<String> totalCheckCompanyIds = new ArrayList<>();
+        for (TotalCheckCompany totalCheckCompany: totalCheckCompanyList){
+            totalCheckCompanyIds.add(totalCheckCompany.getCompanyId());
+        }
+
+
 
-        List<String> totalCompanyIds =  new ArrayList<>();
 
-        for (TotalCheckCompany totalCheckCompany:totalCheckCompanyList){
-            totalCompanyIds.add(totalCheckCompany.getCompanyId());
-        }
 
-        List<String> checkCompanyIds = new ArrayList<>();
+        List<String> checkNumCompanyIds = new ArrayList<>();
         if (checkNumCompanyList.size()>0){
             for (CheckNumCompany checkNumCompany: checkNumCompanyList){
-                checkCompanyIds.add(checkNumCompany.getCompanyId());
                 CompanyInfo companyInfo = companyInfoService.get(checkNumCompany.getCompanyId());
+                checkNumCompanyIds.add(companyInfo.getId());
                 List<CompanyInfo> list = new ArrayList<>();
                 list.add(companyInfo);
                 Integer normal = personDeviceFilterLogService.getDayNormalNumByCompanyId(startTime,endTime,checkNumCompany.getCompanyId());
@@ -83,6 +85,7 @@ public class CheckPersonTask {
                     totalCheckCompany1.setDelFlag(false);
                     totalCheckCompany1.setCreateTime(new Date());
                     totalCheckCompanyService.insert(totalCheckCompany1);
+
                 }else {
                     if (checkNumCompany.getAbnormalNum()>0){
                         totalCheckCompany.setNormalDay(0L);
@@ -96,12 +99,33 @@ public class CheckPersonTask {
                     totalCheckCompany.setTotalAbnormalNum(totalAbnormalNum+checkNumCompany.getAbnormalNum());
                     totalCheckCompany.setUpdateTime(date);
                     totalCheckCompanyService.update(totalCheckCompany);
+
                 }
             }
+
+            boolean success =totalCheckCompanyIds.removeAll(checkNumCompanyIds);
+
+            if (success){
+                for (String companyId : totalCheckCompanyIds){
+                    TotalCheckCompany totalCheckCompany = totalCheckCompanyService.findByCompanyId(companyId);
+                    Long normalDay = totalCheckCompany.getNormalDay();
+                    totalCheckCompany.setNormalDay(normalDay+1L);
+                    totalCheckCompany.setUpdateTime(new Date());
+                    totalCheckCompanyService.update(totalCheckCompany);
+                }
+            }
+        }else {
+            for (TotalCheckCompany totalCheckCompany : totalCheckCompanyList){
+                Long normalDay = totalCheckCompany.getNormalDay();
+                totalCheckCompany.setNormalDay(normalDay+1L);
+                totalCheckCompany.setUpdateTime(new Date());
+                totalCheckCompanyService.update(totalCheckCompany);
+            }
         }
 
 
 
 
+
     }
 }

+ 33 - 6
web/src/test/java/com/jpsoft/smart/LApiTest.java

@@ -1,21 +1,23 @@
 package com.jpsoft.smart;
 
+import cn.hutool.core.date.DateUtil;
 import cn.hutool.json.JSONObject;
+import com.github.pagehelper.Page;
 import com.jpsoft.smart.modules.base.dao.PersonInfoDAO;
 import com.jpsoft.smart.modules.base.dao.WarningPusherDAO;
 import com.jpsoft.smart.modules.base.dto.PersonDeviceLogDTO;
-import com.jpsoft.smart.modules.base.entity.DeviceInfo;
-import com.jpsoft.smart.modules.base.entity.PersonDeviceLog;
-import com.jpsoft.smart.modules.base.entity.PersonInfo;
-import com.jpsoft.smart.modules.base.entity.WarningPusher;
+import com.jpsoft.smart.modules.base.entity.*;
+import com.jpsoft.smart.modules.base.service.CompanyInfoService;
 import com.jpsoft.smart.modules.base.service.PersonDeviceLogService;
 import com.jpsoft.smart.modules.base.service.impl.PersonDeviceLogServiceImpl;
 import com.jpsoft.smart.modules.common.dto.MessageResult;
+import com.jpsoft.smart.modules.common.service.IRedisService;
 import com.jpsoft.smart.modules.common.utils.WechatMessageUtil;
 import com.jpsoft.smart.modules.lapi.service.ILapiService;
 import com.jpsoft.smart.modules.lapi.service.impl.LapiServiceImpl;
 import com.jpsoft.smart.modules.lapi.vo.LapiMsgResult;
 import com.jpsoft.smart.modules.lapi.vo.LapiResult;
+import jdk.nashorn.internal.objects.annotations.Setter;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -45,6 +47,12 @@ public class LApiTest {
     @Autowired
     private PersonDeviceLogServiceImpl personDeviceLogService;
 
+    @Autowired
+    private IRedisService redisService;
+
+    @Autowired
+    private CompanyInfoService companyInfoService;
+
 
 
     @Test
@@ -236,9 +244,27 @@ public class LApiTest {
     public void testSetDeviceRule(){
         try {
 
-           Boolean success = lapiService.setDeviceRule("32acfc7d-e7d4-4ebb-8170-035d00dc92a8",0,1,1,1,new BigDecimal(30),new BigDecimal(45),new BigDecimal(37.3));
+            redisService.put("personInfo","11130","99898",-1);
+        //    List list = redisService.getAll("personInfo");
+          // Boolean success = lapiService.setDeviceRule("32acfc7d-e7d4-4ebb-8170-035d00dc92a8",0,1,1,1,new BigDecimal(30),new BigDecimal(45),new BigDecimal(37.3));
 
-            System.out.println(success);
+       //     System.out.println(list);
+        } catch (Exception e) {
+            e.printStackTrace();
+            String message = e.getMessage();
+        }
+
+    }
+
+    @Test
+    public void testFindLastPersonLogByCompanyList(){
+        try {
+
+            List<CompanyInfo> list = companyInfoService.list();
+
+            Page<PersonDeviceLog> personDeviceLogList =  personDeviceLogService.findLastPersonLogByCompanyList(DateUtil.beginOfDay(new Date()), DateUtil.endOfDay(new Date()), list,0,1);
+
+                 System.out.println(personDeviceLogList);
         } catch (Exception e) {
             e.printStackTrace();
             String message = e.getMessage();
@@ -247,4 +273,5 @@ public class LApiTest {
     }
 
 
+
 }