Administrator пре 5 година
родитељ
комит
4deb16c3bb

+ 1 - 0
common/src/main/java/com/jpsoft/smart/modules/base/dao/CompanyInfoDAO.java

@@ -37,4 +37,5 @@ public interface CompanyInfoDAO {
     List<CompanyInfo> findByParentId(@Param("parentId") String parentId);
 
 	CompanyInfo findByName(String name);
+
 }

+ 2 - 0
common/src/main/java/com/jpsoft/smart/modules/base/dao/PersonDeviceLogDAO.java

@@ -57,4 +57,6 @@ public interface PersonDeviceLogDAO {
     List<PersonDeviceLog> findExpiredVisitorRecord(@Param("limit") int limit);
 
     long countByAttendance(String companyCode, Date beginDate, Date endDate);
+
+    Integer getDayAbnormalNumByDeviceNoList(DateTime dateTime, Date date, List<String> deviceNoList, float max);
 }

+ 2 - 0
common/src/main/java/com/jpsoft/smart/modules/base/service/PersonDeviceLogService.java

@@ -57,4 +57,6 @@ public interface PersonDeviceLogService {
     int delete(String id);
 
     long countByAttendance(String companyCode, Date beginDate, Date endDate);
+
+    Integer getDayAbnormalNumByDeviceNoList(DateTime dateTime, Date date, List<String> deviceNoList);
 }

+ 2 - 0
common/src/main/java/com/jpsoft/smart/modules/base/service/impl/CompanyInfoServiceImpl.java

@@ -102,4 +102,6 @@ public class CompanyInfoServiceImpl implements CompanyInfoService {
 	public CompanyInfo findByName(String name) {
 		return companyInfoDAO.findByName(name);
 	}
+
+
 }

+ 37 - 4
common/src/main/java/com/jpsoft/smart/modules/base/service/impl/PersonDeviceFilterLogServiceImpl.java

@@ -10,9 +10,7 @@ import com.jpsoft.smart.config.TemperatureConfig;
 import com.jpsoft.smart.modules.base.dao.PersonDeviceFilterLogDAO;
 import com.jpsoft.smart.modules.base.dao.PersonDeviceLogDAO;
 import com.jpsoft.smart.modules.base.entity.*;
-import com.jpsoft.smart.modules.base.service.CheckNumCompanyService;
-import com.jpsoft.smart.modules.base.service.PersonDeviceFilterLogService;
-import com.jpsoft.smart.modules.base.service.PersonInfoService;
+import com.jpsoft.smart.modules.base.service.*;
 import com.jpsoft.smart.modules.common.dto.Sort;
 import com.jpsoft.smart.modules.common.utils.LApiUtil;
 import com.jpsoft.smart.modules.common.utils.OSSUtil;
@@ -46,6 +44,9 @@ public class PersonDeviceFilterLogServiceImpl implements PersonDeviceFilterLogSe
     @Autowired
     private PersonInfoService personInfoService;
 
+    @Autowired
+    private DeviceInfoService deviceInfoService;
+
     @Autowired
     private CheckNumCompanyService checkNumCompanyService;
 
@@ -93,6 +94,7 @@ public class PersonDeviceFilterLogServiceImpl implements PersonDeviceFilterLogSe
             String recordTimeZons = DateUtil.format(date, "yyyy-MM-dd-HH-mm");
             String timeZones = TimeZonesUtil.getUpperTimeZone(recordTimeZons);
             PersonInfo personInfo = LApiUtil.getPersonCode(libMatInfoListJson, matchPersonInfo);
+            DeviceInfo deviceInfo = deviceInfoService.getByDeviceNo(deviceNo);
 
       //      PersonInfo personInfoReturn = personInfoService.addPersonForCompany(personInfo,deviceNo);
            // Integer personId = LApiUtil.getPersonCode(libMatInfoListJson, matchPersonInfo);
@@ -159,6 +161,9 @@ public class PersonDeviceFilterLogServiceImpl implements PersonDeviceFilterLogSe
                     }
                 }).start();
             }
+            if (personInfo.getId() == 0L && temperature.compareTo(BigDecimal.valueOf(temperatureConfig.getMax())) == 1){
+                addVisitorCheckNumForCompany(deviceInfo.getCompanyId(), temperature, date);
+            }
 
         } catch (Exception e) {
 
@@ -190,6 +195,28 @@ public class PersonDeviceFilterLogServiceImpl implements PersonDeviceFilterLogSe
         }
     }
 
+    public void addVisitorCheckNumForCompany(String companyId, BigDecimal temperature, Date date) {
+
+        String recordTime = DateUtil.format(date, "yyyy-MM-dd");
+
+        if (StringUtils.isNotBlank(companyId)) {
+            CheckNumCompany checkNumCompany = checkNumCompanyService.findByCompanyIdAndRecordTime(companyId, recordTime);
+            if (checkNumCompany != null) {
+                Integer checkNum = checkNumCompany.getCheckNum().intValue() + 1;
+                checkNumCompany.setCheckNum(checkNum.longValue());
+                checkNumCompanyService.update(checkNumCompany);
+            } else {
+                CheckNumCompany checkNumCompany1 = new CheckNumCompany();
+                checkNumCompany1.setCompanyId(companyId);
+                checkNumCompany1.setCheckNum(1L);
+                checkNumCompany1.setDelFlag(false);
+                checkNumCompany1.setRecordTime(recordTime);
+                checkNumCompany1.setCreateTime(new Date());
+                checkNumCompanyService.insert(checkNumCompany1);
+            }
+        }
+    }
+
     @Override
     public Page<PersonDeviceFilterLog> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize, boolean count, List<Sort> sortList) {
         Page<PersonDeviceFilterLog> page = PageHelper.startPage(pageNumber, pageSize, count).doSelectPage(() -> {
@@ -272,7 +299,13 @@ public class PersonDeviceFilterLogServiceImpl implements PersonDeviceFilterLogSe
 
     @Override
     public Integer getDayAbnormalNumByCompanyList(Date startTime, Date endTime, List<CompanyInfo> list) {
-        return personDeviceFilterLogDAO.getDayAbnormalNumByCompanyList(startTime,endTime,list,temperatureConfig.getMax());
+        Integer total = personDeviceFilterLogDAO.getDayAbnormalNumByCompanyList(startTime,endTime,list,temperatureConfig.getMax());
+       if (total == null){
+           return 0;
+       }else {
+           return total;
+       }
+
     }
 
     @Override

+ 12 - 0
common/src/main/java/com/jpsoft/smart/modules/base/service/impl/PersonDeviceLogServiceImpl.java

@@ -232,6 +232,18 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
         return personDeviceLogDAO.countByAttendance(companyCode,beginDate,endDate);
     }
 
+    @Override
+    public Integer getDayAbnormalNumByDeviceNoList(DateTime dateTime, Date date, List<String> deviceNoList) {
+        Integer total = personDeviceLogDAO.getDayAbnormalNumByDeviceNoList(dateTime,date,deviceNoList,temperatureConfig.getMax());
+        if (total == null){
+            return 0;
+        }else{
+            return total;
+        }
+
+
+    }
+
     @Override
     public PersonDeviceLog findLastPersonLog(Long personId, float temperatureMax) {
         return personDeviceLogDAO.findLastPersonLog(personId,temperatureMax);

+ 7 - 1
common/src/main/java/com/jpsoft/smart/modules/base/service/impl/TotalCheckCompanyServiceImpl.java

@@ -43,7 +43,13 @@ public class TotalCheckCompanyServiceImpl implements TotalCheckCompanyService {
 
     @Override
     public Integer getTotalAbnormalNumByCompanyList(List<CompanyInfo> list) {
-        return totalCheckCompanyDAO.getTotalAbnormalNumByCompanyList(list);
+        Integer total = totalCheckCompanyDAO.getTotalAbnormalNumByCompanyList(list);
+        if (total == null){
+            return 0;
+        }else {
+            return total;
+        }
+
     }
 
     @Override

+ 13 - 0
common/src/main/resources/mapper/base/PersonDeviceLog.xml

@@ -420,4 +420,17 @@
             and c.del_flag=0
         ]]>
     </select>
+
+    <select id="getDayAbnormalNumByDeviceNoList" resultType="Integer">
+        <![CDATA[
+        select count(*) from base_person_device_log a
+        where a.record_time >=#{startTime}
+        and a.record_time <= #{endTime}
+        and a.temperature_>#{temperatureMax}
+        and a.person_id = 0
+        ]]>
+        <foreach collection="list" index="index" item="item" open="and a.device_no in(" separator="," close=")">#{item}
+        </foreach>
+        and a.del_flag = 0
+    </select>
 </mapper>

+ 10 - 3
web/src/main/java/com/jpsoft/smart/modules/mobile/controller/HealthShowApiController.java

@@ -145,10 +145,11 @@ public class HealthShowApiController {
                 //   Integer totalCheckNum = totalNum == null ? dayCheckNum : totalNum + dayCheckNum;
                 Integer totalCheckNum = checkPersonTotal + checkedVisitorNum;
 
+                Integer num1 = personDeviceLogService.getDayAbnormalNumByDeviceNoList(DateUtil.beginOfDay(new Date()), new Date(), deviceNoList);
                 Integer num2 = personDeviceFilterLogService.getDayAbnormalNumByCompanyList(DateUtil.beginOfDay(new Date()), new Date(), list);
                 Integer totalNum2 = totalCheckCompanyService.getTotalAbnormalNumByCompanyList(list);
-                Integer dayAbnormalNum = num2 == null ? 0 : num2;
-                Integer totalAbnormalNum = totalNum2 == null ? 0 : totalNum2 + dayAbnormalNum;
+                Integer dayAbnormalNum = num1+num2;
+                Integer totalAbnormalNum =  totalNum2 + dayAbnormalNum;
 
                 Integer normalDaysNum = totalCheckCompanyService.findMinNormalDayByCompanyList(list);
                 Integer normalDays = normalDaysNum == null ? 0 : normalDaysNum;
@@ -353,14 +354,20 @@ public class HealthShowApiController {
                 Integer dayCheckNum = num == null ? 0 : num;
                 Integer totalCheckNum = totalNum == null ? dayCheckNum : totalNum + dayCheckNum;
 
+
+                Integer num1 = personDeviceLogService.getDayAbnormalNumByDeviceNoList(DateUtil.beginOfDay(new Date()), new Date(), deviceNoList);
                 Integer num2 = personDeviceFilterLogService.getDayAbnormalNumByCompanyList(DateUtil.beginOfDay(new Date()), new Date(), list);
                 Integer totalNum2 = totalCheckCompanyService.getTotalAbnormalNumByCompanyList(list);
+                Integer dayAbnormalNum = num1+num2;
+                Integer totalAbnormalNum =  totalNum2 + dayAbnormalNum;
+               /* Integer num2 = personDeviceFilterLogService.getDayAbnormalNumByCompanyList(DateUtil.beginOfDay(new Date()), new Date(), list);
+                Integer totalNum2 = totalCheckCompanyService.getTotalAbnormalNumByCompanyList(list);
 
                 //当日异常
                 Integer dayAbnormalNum = num2 == null ? 0 : num2;
 
                 //总异常
-                Integer totalAbnormalNum = totalNum2 == null ? 0 : totalNum2 + dayAbnormalNum;
+                Integer totalAbnormalNum = totalNum2 == null ? 0 : totalNum2 + dayAbnormalNum;*/
 
                 Integer normalDaysNum = totalCheckCompanyService.findMinNormalDayByCompanyList(list);
                 //连续无异常天数