Przeglądaj źródła

健康公示上面数字与曲线匹配。

zhengqiang 5 lat temu
rodzic
commit
c73484528d

+ 1 - 0
common/src/main/resources/mapper/business/WorkAttendance.xml

@@ -97,6 +97,7 @@
 			select * from business_work_attendance
 		]]>
         <where>
+            del_flag=0
             <if test="searchParams.personId != null">
                 and person_id like #{searchParams.personId}
             </if>

+ 1 - 0
web/src/main/java/com/jpsoft/smart/modules/base/controller/AlarmConfigController.java

@@ -248,6 +248,7 @@ public class AlarmConfigController {
 
         List<Sort> sortList = new ArrayList<>();
         sortList.add(new Sort("a.company_id","asc"));
+        sortList.add(new Sort("a.weekdays_","asc"));
         sortList.add(new Sort("a.start_time","asc"));
 
         if (StringUtils.isNotEmpty(companyId)) {

+ 1 - 1
web/src/main/java/com/jpsoft/smart/modules/business/controller/WorkAttendanceController.java

@@ -215,7 +215,7 @@ public class WorkAttendanceController {
 
             //todo 保存到redis
             String tmplKey = "workAttendance_" + DateTime.now().toString("yyMMddHHmmssSSS");
-            valueOperations.set(tmplKey,personMapList,5, TimeUnit.MINUTES);
+            valueOperations.set(tmplKey,personMapList,30, TimeUnit.MINUTES);
 
             dataMap.put("list",personMapList);
 //          dataMap.put("url",downloadUrl);

+ 41 - 63
web/src/main/java/com/jpsoft/smart/modules/mobile/controller/IndividualLogApiController.java

@@ -120,7 +120,7 @@ public class IndividualLogApiController {
             map.put("temperatureMax", temperatureConfig.getMax());
             map.put("faceImageUrl",person.getFaceImageUrl());
 
-            PersonDeviceLog lastPersonLog = personDeviceLogService.findLastPersonLog(person.getId(),temperatureConfig.getMax());
+            PersonDeviceFilterLog lastPersonLog = personDeviceFilterLogService.lastPersonLog(person.getId());
 
             BigDecimal lastTemperature = lastPersonLog.getTemperature();
 
@@ -140,59 +140,6 @@ public class IndividualLogApiController {
                 map.put("isNormal",true);
             }
 
-            DateTime today = DateTime.now().withTimeAtStartOfDay();
-
-            //todo 最近14天未测体温数
-            Integer detectedCount = personDeviceFilterLogService.countDayByPersonIdAndDate(person.getId(),today.minusDays(13).toDate(),today.plusDays(1).toDate());
-            map.put("undetectedCount",14 - detectedCount);
-
-            //todo 获取连续检测天数
-            //最近一年的节假日
-            Set<String> holidaySet = holidayInfoService.getHolidaySetByDate(today.minusDays(364).toDate(),today.plusDays(1).toDate());
-
-            //查询当前用户的考勤设置
-            Set<Integer> weekdaySet = alarmConfigService.getWeekdaySetByCompanyId(person.getCompanyId());
-
-            int totalDays = 0;
-
-            //最多查一年
-            for(int i=0;i<365;i++) {
-                DateTime prevDay = today.minusDays(i);
-
-                DateTime startTime = prevDay;
-                DateTime endTime = prevDay.plusDays(1);
-
-                PersonDeviceFilterLog item = personDeviceFilterLogService.findByPersonOrderTemperature(person.getId(), startTime.toString("yyyy-MM-dd"), endTime.toString("yyyy-MM-dd"));
-
-                if(item!=null){
-                    float curTemperature = item.getTemperature().floatValue();
-
-                    if(curTemperature<=temperatureConfig.getMax()){
-                        totalDays++;
-                    }
-                    else{
-                        //有异常温度跳出循环
-                        break;
-                    }
-                }
-                else{
-                    if (!weekdaySet.contains(startTime.getDayOfWeek())){
-                        //先排除一周非工作日
-                        continue;
-                    }
-                    else if (holidaySet.contains(startTime.toString("yyyy-MM-dd"))){
-                        //再排除节假日
-                        continue;
-                    }
-                    else if(i!=0) {
-                        //之前无测温记录则跳出循环
-                        break;
-                    }
-                }
-            }
-
-            map.put("totalDays",totalDays);
-
             messageResult.setResult(true);
             messageResult.setData(map);
         }
@@ -225,6 +172,8 @@ public class IndividualLogApiController {
 
             Map<String, Object> map = new HashMap<>();
             DateTime now = DateTime.now();
+
+            //最近14天
             DateTime startTime = now.minusDays(13);
             DateTime endTime = now;
 
@@ -235,27 +184,41 @@ public class IndividualLogApiController {
 
             SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
             PersonDeviceFilterLog lastPersonLog = personDeviceFilterLogService.lastPersonLog(person.getId());
-            String lastDateStr = sdf.format(lastPersonLog.getRecordTime());
+
+            String lastDateStr = DateTime.now().toString("yyyy-MM-dd");
+
+            if(lastPersonLog!=null) {
+                sdf.format(lastPersonLog.getRecordTime());
+            }
+
+            DateTime today = DateTime.now().withTimeAtStartOfDay();
+            int undetectedCount = 0; //未测温天数
+            int totalDays = 0;       //连续测温天数
+
+            //最近一年的节假日
+            Set<String> holidaySet = holidayInfoService.getHolidaySetByDate(today.minusDays(364).toDate(),today.plusDays(1).toDate());
+
+            //查询当前用户的考勤设置
+            Set<Integer> weekdaySet = alarmConfigService.getWeekdaySetByCompanyId(person.getCompanyId());
 
             for (int i =0;i<14;i++) {
                 Map<String, Object> map1 = new HashMap<>();
-                DateTime today = startTime.plusDays(i);
+                DateTime curDay = startTime.plusDays(i);
 
-                String startDate = today.toString("yyyy-MM-dd");
-                String endDate = today.plusDays(1).toString("yyyy-MM-dd");
+                String startDate = curDay.toString("yyyy-MM-dd");
+                String endDate = curDay.plusDays(1).toString("yyyy-MM-dd");
 
-                PersonDeviceFilterLog personDeviceFilterLog = null;
+                PersonDeviceFilterLog personDeviceFilterLog;
 
-                if (lastDateStr.equals(startDate)){
+                if (lastDateStr.equals(startDate) && lastPersonLog!=null){
                     personDeviceFilterLog = lastPersonLog;
                 }
                 else{
-                    personDeviceFilterLog  = personDeviceFilterLogService.findByPersonOrderTemperature(person.getId(), startDate, endDate);
+                    personDeviceFilterLog = personDeviceFilterLogService.findByPersonOrderTemperature(person.getId(), startDate, endDate);
                 }
 
                 if (personDeviceFilterLog != null) {
                     boolean isDanger = false;
-
                     map1.put("name", today.toString("MM-dd"));
                     map1.put("value", personDeviceFilterLog.getTemperature());
 
@@ -264,18 +227,33 @@ public class IndividualLogApiController {
                     }
 
                     map1.put("danger", isDanger);
+                    totalDays++;
                 }
                 else{
+                    //如果没有记录,先判断是否非工作日
+                    if (!weekdaySet.contains(startTime.getDayOfWeek())){
+                        //先排除一周非工作日
+                        continue;
+                    }
+                    else if (holidaySet.contains(startTime.toString("yyyy-MM-dd"))){
+                        //再排除节假日
+                        continue;
+                    }
+
+                    //工作日没有记录,则显示为0
                     map1.put("name", today.toString("MM-dd"));
                     map1.put("value", 0);
                     map1.put("danger", false);
+                    undetectedCount++;
                 }
 
                 list1.add(map1);
             }
 
             map.put("list", list1);
-            map.put("temperatureMax",temperatureConfig.getMax());
+            map.put("temperatureMax", temperatureConfig.getMax());
+            map.put("undetectedCount", undetectedCount);
+            map.put("totalDays", totalDays);
 
             totalList.add(map);
 

+ 3 - 1
web/src/main/java/com/jpsoft/smart/modules/mobile/controller/WorkAttendanceApiController.java

@@ -65,7 +65,9 @@ public class WorkAttendanceApiController {
 
             Page<WorkAttendance> page = workAttendanceService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
 
-            msgResult.setData(PojoUtils.pageWrapper(page));
+            Map<String,Object> dataMap = PojoUtils.pageWrapper(page);
+
+            msgResult.setData(dataMap);
             msgResult.setResult(true);
         }
         catch (Exception ex){