|
@@ -1,12 +1,241 @@
|
|
|
package com.jpsoft.smart.modules.mobile.controller;
|
|
|
|
|
|
+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.common.dto.MessageResult;
|
|
|
+import com.jpsoft.smart.modules.common.dto.Sort;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Slf4j
|
|
|
@RestController
|
|
|
@RequestMapping("/mobile/IndividualLogApi")
|
|
|
public class IndividualLogApiController {
|
|
|
+ @Autowired
|
|
|
+ private PersonInfoService personInfoService;
|
|
|
+ @Autowired
|
|
|
+ private PersonDeviceFilterLogService personDeviceFilterLogService;
|
|
|
+
|
|
|
+ @PostMapping("healthyPersonList")
|
|
|
+ @ApiOperation(value="健康公示列表")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name="token",value = "令牌",required = true,paramType = "form"),
|
|
|
+ @ApiImplicitParam(name="subject",value = "目标(不传)",paramType = "form")
|
|
|
+ })
|
|
|
+ public MessageResult<List<PersonInfo>> healthyPersonList(
|
|
|
+ String token,
|
|
|
+ @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
|
|
|
+ @RequestParam(value="pageSize",defaultValue="20") int pageSize,
|
|
|
+ @RequestAttribute String subject){
|
|
|
+ MessageResult<List<PersonInfo>> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try{
|
|
|
+ PersonInfo admin = personInfoService.get(Long.valueOf(subject));
|
|
|
+
|
|
|
+ String companyId = admin.getCompanyId();
|
|
|
+
|
|
|
+ Map<String,Object> searchParams = new HashMap<>();
|
|
|
+
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("a.create_time","desc"));
|
|
|
+
|
|
|
+ searchParams.put("companyId",companyId);
|
|
|
+
|
|
|
+ List<PersonInfo> personInfoList = personInfoService.pageSearch(searchParams,pageIndex,pageSize,false,sortList);
|
|
|
+
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setData(personInfoList);
|
|
|
+ }
|
|
|
+ catch (Exception ex){
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("temperaturePersonDetail")
|
|
|
+ @ApiOperation(value="人员体温详情")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name="personId",value = "人员ID",required = true,paramType = "form"),
|
|
|
+ @ApiImplicitParam(name="token",value = "令牌",required = true,paramType = "form"),
|
|
|
+ @ApiImplicitParam(name="subject",value = "目标(不传)",paramType = "form")
|
|
|
+ })
|
|
|
+ public MessageResult<Map> temperaturePersonDetail(
|
|
|
+ String personId, String token,
|
|
|
+ @RequestAttribute String subject){
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+
|
|
|
+ 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;
|
|
|
+ if(lastTemperature != null){
|
|
|
+ lastTemperatureStr = String.valueOf(lastTemperature);
|
|
|
+ lastTemperatureDou = Double.parseDouble(lastTemperatureStr);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ lastTemperatureStr = "无记录";
|
|
|
+ }
|
|
|
+ map.put("lastTemperature",lastTemperatureStr);
|
|
|
+
|
|
|
+ if(lastTemperatureDou>=37){
|
|
|
+ map.put("isNormal","异常");
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ map.put("isNormal","正常");
|
|
|
+ }
|
|
|
+
|
|
|
+ double curTemperature = 0;
|
|
|
+
|
|
|
+ int totalDays = 0;
|
|
|
+
|
|
|
+ int i = 0;
|
|
|
+
|
|
|
+ Date now = new Date();
|
|
|
+
|
|
|
+ while (curTemperature < 37) {
|
|
|
+
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+
|
|
|
+ Calendar rightNow = Calendar.getInstance();
|
|
|
+ rightNow.setTime(now);
|
|
|
+ rightNow.add(Calendar.DATE, -(i+1));
|
|
|
+ Date dt1 = rightNow.getTime();
|
|
|
+ String startDate = sdf.format(dt1);
|
|
|
+
|
|
|
+ Calendar rightNow2 = Calendar.getInstance();
|
|
|
+ rightNow2.setTime(now);
|
|
|
+ rightNow2.add(Calendar.DATE, -i);
|
|
|
+ Date dt2 = rightNow2.getTime();
|
|
|
+ String endDate = sdf.format(dt2);
|
|
|
+
|
|
|
+ PersonDeviceFilterLog item = personDeviceFilterLogService.getByPersonIdAndDate(person.getId(), startDate, endDate);
|
|
|
+
|
|
|
+ if(item!=null){
|
|
|
+ String temperature = item.getTemperature().toString();
|
|
|
+
|
|
|
+ curTemperature = Double.parseDouble(temperature);
|
|
|
+
|
|
|
+ if(curTemperature<37){
|
|
|
+ totalDays++;
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ //有异常温度跳出循环
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ //无记录则跳出循环
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ map.put("totalDays",totalDays);
|
|
|
+
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setData(map);
|
|
|
+ }
|
|
|
+ catch (Exception ex){
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("temperaturePersonCurve")
|
|
|
+ @ApiOperation(value="人员温度曲线接口")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name="personId",value = "人员ID",required = true,paramType = "form"),
|
|
|
+ @ApiImplicitParam(name="token",value = "令牌",required = true,paramType = "form"),
|
|
|
+ @ApiImplicitParam(name="subject",value = "目标(不传)",paramType = "form")
|
|
|
+ })
|
|
|
+ public MessageResult<List<Map<String,Object>>> temperaturePersonCurve(
|
|
|
+ String personId, String token,
|
|
|
+ @RequestAttribute String subject){
|
|
|
+
|
|
|
+ MessageResult<List<Map<String,Object>>> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ List<Map<String,Object>> totalList = new ArrayList<>();
|
|
|
+
|
|
|
+ Date now = new Date();
|
|
|
+ PersonInfo person = personInfoService.get(Long.valueOf(personId));
|
|
|
+
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ SimpleDateFormat f = new SimpleDateFormat("HH");
|
|
|
+
|
|
|
+ for (int i = 0;i < 14;i++) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+
|
|
|
+ Calendar rightNow = Calendar.getInstance();
|
|
|
+ rightNow.setTime(now);
|
|
|
+ rightNow.add(Calendar.DATE, -(i + 1));
|
|
|
+ Date dt1 = rightNow.getTime();
|
|
|
+ String startDate = sdf.format(dt1);
|
|
|
+
|
|
|
+ Calendar rightNow2 = Calendar.getInstance();
|
|
|
+ rightNow2.setTime(now);
|
|
|
+ rightNow2.add(Calendar.DATE, -i);
|
|
|
+ Date dt2 = rightNow2.getTime();
|
|
|
+ String endDate = sdf.format(dt2);
|
|
|
+
|
|
|
+ List<PersonDeviceFilterLog> personDeviceLogList = personDeviceFilterLogService.findByPersonAndDate(person.getId(),startDate,endDate);
|
|
|
+
|
|
|
+ map.put("date",startDate);
|
|
|
+
|
|
|
+ List<Map<String,Object>> list = new ArrayList<>();
|
|
|
+ boolean isDanger = false;
|
|
|
+ for (PersonDeviceFilterLog personDeviceFilterLog:personDeviceLogList) {
|
|
|
+ Map<String, Object> mapChi = new HashMap<>();
|
|
|
+ Date recordTime = personDeviceFilterLog.getRecordTime();
|
|
|
+ String hour = f.format(recordTime);
|
|
|
+
|
|
|
+ mapChi.put("name",hour+"时");
|
|
|
+ mapChi.put("value",personDeviceFilterLog.getTemperature());
|
|
|
+ double temperatureDou = Double.parseDouble(personDeviceFilterLog.getTemperature().toString());
|
|
|
+ if(temperatureDou>=37){
|
|
|
+ isDanger = true;
|
|
|
+ }
|
|
|
+ list.add(mapChi);
|
|
|
+ }
|
|
|
+
|
|
|
+ map.put("list",list);
|
|
|
+ map.put("danger",isDanger);
|
|
|
+
|
|
|
+ totalList.add(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ messageResult.setData(totalList);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ }
|
|
|
+ catch (Exception ex){
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ messageResult.setResult(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
|
|
|
+ }
|
|
|
}
|