|
@@ -2,10 +2,12 @@ package com.jpsoft.smart.modules.mobile.controller;
|
|
|
|
|
|
import com.github.pagehelper.Page;
|
|
|
import com.jpsoft.smart.config.TemperatureConfig;
|
|
|
+import com.jpsoft.smart.modules.base.entity.AlarmConfig;
|
|
|
+import com.jpsoft.smart.modules.base.entity.CompanyInfo;
|
|
|
import com.jpsoft.smart.modules.base.entity.PersonDeviceFilterLog;
|
|
|
import com.jpsoft.smart.modules.base.entity.PersonInfo;
|
|
|
-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.business.service.WorkAttendanceService;
|
|
|
import com.jpsoft.smart.modules.common.dto.MessageResult;
|
|
|
import com.jpsoft.smart.modules.common.dto.Sort;
|
|
|
import com.jpsoft.smart.modules.common.utils.PojoUtils;
|
|
@@ -18,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.text.DecimalFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
@@ -27,11 +30,22 @@ import java.util.*;
|
|
|
public class IndividualLogApiController {
|
|
|
@Autowired
|
|
|
private PersonInfoService personInfoService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private PersonDeviceFilterLogService personDeviceFilterLogService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private TemperatureConfig temperatureConfig;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private HolidayInfoService holidayInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CompanyInfoService companyInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AlarmConfigService alarmConfigService;
|
|
|
+
|
|
|
@PostMapping("healthyPersonList")
|
|
|
@ApiOperation(value="健康公示列表")
|
|
|
@ApiImplicitParams({
|
|
@@ -101,53 +115,63 @@ public class IndividualLogApiController {
|
|
|
|
|
|
try{
|
|
|
PersonInfo person = personInfoService.get(Long.valueOf(personId));
|
|
|
+
|
|
|
map.put("name",person.getName());
|
|
|
map.put("faceImageUrl",person.getFaceImageUrl());
|
|
|
|
|
|
PersonDeviceFilterLog personDeviceFilterLog = personDeviceFilterLogService.lastPersonLog(person.getId());
|
|
|
|
|
|
BigDecimal lastTemperature = personDeviceFilterLog.getTemperature();
|
|
|
- String lastTemperatureStr = "";
|
|
|
- double lastTemperatureDou = 0;
|
|
|
+ DecimalFormat df = new DecimalFormat("##.#");
|
|
|
+
|
|
|
if(lastTemperature != null){
|
|
|
- lastTemperatureStr = String.valueOf(lastTemperature);
|
|
|
- lastTemperatureDou = Double.parseDouble(lastTemperatureStr);
|
|
|
+ map.put("lastTemperature",df.format(lastTemperature));
|
|
|
}
|
|
|
else{
|
|
|
- lastTemperatureStr = "无记录";
|
|
|
+ map.put("lastTemperature","无记录");
|
|
|
}
|
|
|
- map.put("lastTemperature",lastTemperatureStr);
|
|
|
|
|
|
- if(lastTemperatureDou>temperatureConfig.getMax()){
|
|
|
+ if(lastTemperature.floatValue() > temperatureConfig.getMax()){
|
|
|
map.put("isNormal",false);
|
|
|
}
|
|
|
else{
|
|
|
map.put("isNormal",true);
|
|
|
}
|
|
|
|
|
|
- double curTemperature = 0;
|
|
|
+ DateTime today = DateTime.now().withTimeAtStartOfDay();
|
|
|
|
|
|
- int totalDays = 0;
|
|
|
+ //todo 最近14天未测体温数
|
|
|
+ Integer detectedCount = personDeviceFilterLogService.countDayByPersonIdAndDate(person.getId(),today.minusDays(13).toDate(),today.plusDays(1).toDate());
|
|
|
+ map.put("unDetectedCount",14 - detectedCount);
|
|
|
|
|
|
- int i = 0;
|
|
|
+ //todo 获取连续检测天数
|
|
|
+ //最近一年的节假日
|
|
|
+ Set<String> holidaySet = holidayInfoService.getHolidaySetByDate(today.minusDays(364).toDate(),today.plusDays(1).toDate());
|
|
|
|
|
|
- DateTime today = DateTime.now().withTimeAtStartOfDay();
|
|
|
+ //查询当前用户的考勤设置
|
|
|
+ Set<Integer> weekdaySet = alarmConfigService.getWeekdaySetByCompanyId(person.getCompanyId());
|
|
|
+
|
|
|
+ int totalDays = 0;
|
|
|
|
|
|
//最多查一年
|
|
|
- while (i<=365) {
|
|
|
- DateTime startTime = today.minusDays(i+1);
|
|
|
- DateTime endTime = today.minusDays(i);
|
|
|
+ for(int i=0;i<365;i++) {
|
|
|
+ DateTime startTime = today.minusDays(i);
|
|
|
+ DateTime endTime = today.minusDays(i-1);
|
|
|
+
|
|
|
+ //先排除一周非工作日
|
|
|
+ if (!weekdaySet.contains(startTime.getDayOfWeek())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
- //先排除星期天
|
|
|
- if (startTime.getDayOfWeek()==7){
|
|
|
- i++;
|
|
|
+ //再排除节假日
|
|
|
+ if (holidaySet.contains(startTime.toString("yyyy-MM-dd"))){
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
PersonDeviceFilterLog item = personDeviceFilterLogService.findByPersonOrderTemperature(person.getId(), startTime.toString("yyyy-MM-dd"), endTime.toString("yyyy-MM-dd"));
|
|
|
|
|
|
if(item!=null){
|
|
|
- curTemperature = item.getTemperature().doubleValue();
|
|
|
+ float curTemperature = item.getTemperature().floatValue();
|
|
|
|
|
|
if(curTemperature<=temperatureConfig.getMax()){
|
|
|
totalDays++;
|
|
@@ -159,8 +183,10 @@ public class IndividualLogApiController {
|
|
|
}
|
|
|
}
|
|
|
else{
|
|
|
- //无记录则跳出循环
|
|
|
- break;
|
|
|
+ //之前无测温记录则跳出循环
|
|
|
+ if(i!=0) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -196,54 +222,60 @@ public class IndividualLogApiController {
|
|
|
|
|
|
PersonInfo person = personInfoService.get(Long.valueOf(personId));
|
|
|
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- SimpleDateFormat f = new SimpleDateFormat("MM-dd");
|
|
|
-
|
|
|
- for (int j = 2; j >=0;j--) {
|
|
|
-
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ DateTime now = DateTime.now();
|
|
|
+ DateTime startTime = now.minusDays(13);
|
|
|
+ DateTime endTime = now;
|
|
|
|
|
|
- map.put("startDate", sdf.format(DateTime.now().plusDays(-14-(j*14)).toDate()));
|
|
|
- map.put("endDate", sdf.format(DateTime.now().plusDays(-(j*14)).toDate()));
|
|
|
+ map.put("startDate", startTime.toString("yyyy-MM-dd"));
|
|
|
+ map.put("endDate", endTime.toString("yyyy-MM-dd"));
|
|
|
|
|
|
- List<Map<String, Object>> list1 = new ArrayList<>();
|
|
|
+ List<Map<String, Object>> list1 = new ArrayList<>();
|
|
|
|
|
|
- for (int i = 13; i >=0; i--) {
|
|
|
- Map<String, Object> map1 = new HashMap<>();
|
|
|
-
|
|
|
- String startDate = sdf.format(DateTime.now().plusDays( - i-(j*14)).toDate());
|
|
|
-
|
|
|
- String endDate = sdf.format(DateTime.now().plusDays(1 - i-(j*14)).toDate());
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ PersonDeviceFilterLog lastPersonLog = personDeviceFilterLogService.lastPersonLog(person.getId());
|
|
|
+ String lastDateStr = sdf.format(lastPersonLog.getRecordTime());
|
|
|
|
|
|
- PersonDeviceFilterLog personDeviceFilterLog = personDeviceFilterLogService.findByPersonOrderTemperature(person.getId(), startDate, endDate);
|
|
|
+ for (int i =0;i<14;i++) {
|
|
|
+ Map<String, Object> map1 = new HashMap<>();
|
|
|
+ DateTime today = startTime.plusDays(i);
|
|
|
|
|
|
- if (personDeviceFilterLog != null) {
|
|
|
+ String startDate = today.toString("yyyy-MM-dd");
|
|
|
+ String endDate = today.plusDays(1).toString("yyyy-MM-dd");
|
|
|
|
|
|
- Date recordTime = personDeviceFilterLog.getRecordTime();
|
|
|
- String hour = f.format(recordTime);
|
|
|
+ PersonDeviceFilterLog personDeviceFilterLog = null;
|
|
|
|
|
|
- boolean isDanger = false;
|
|
|
+ if (lastDateStr.equals(startDate)){
|
|
|
+ personDeviceFilterLog = lastPersonLog;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ personDeviceFilterLog = personDeviceFilterLogService.findByPersonOrderTemperature(person.getId(), startDate, endDate);
|
|
|
+ }
|
|
|
|
|
|
- map1.put("name", hour);
|
|
|
- map1.put("value", personDeviceFilterLog.getTemperature());
|
|
|
- double temperatureDou = Double.parseDouble(personDeviceFilterLog.getTemperature().toString());
|
|
|
- if (temperatureDou > temperatureConfig.getMax()) {
|
|
|
- isDanger = true;
|
|
|
- }
|
|
|
+ if (personDeviceFilterLog != null) {
|
|
|
+ boolean isDanger = false;
|
|
|
|
|
|
- map1.put("danger", isDanger);
|
|
|
+ map1.put("name", today.toString("MM-dd"));
|
|
|
+ map1.put("value", personDeviceFilterLog.getTemperature());
|
|
|
|
|
|
- list1.add(map1);
|
|
|
+ if (personDeviceFilterLog.getTemperature().floatValue() > temperatureConfig.getMax()) {
|
|
|
+ isDanger = true;
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- if(list1.size()>0) {
|
|
|
- map.put("list", list1);
|
|
|
|
|
|
- totalList.add(map);
|
|
|
+ map1.put("danger", isDanger);
|
|
|
}
|
|
|
+ else{
|
|
|
+ map1.put("name", today.toString("MM-dd"));
|
|
|
+ map1.put("value", 0);
|
|
|
+ map1.put("danger", false);
|
|
|
+ }
|
|
|
+
|
|
|
+ list1.add(map1);
|
|
|
}
|
|
|
|
|
|
+ map.put("list", list1);
|
|
|
+ totalList.add(map);
|
|
|
+
|
|
|
messageResult.setData(totalList);
|
|
|
messageResult.setResult(true);
|
|
|
}
|