浏览代码

管理端新增接口

yanliming 5 年之前
父节点
当前提交
ac764ae101

+ 4 - 0
common/src/main/java/com/jpsoft/smart/modules/base/dao/PersonDeviceFilterLogDAO.java

@@ -36,4 +36,8 @@ public interface PersonDeviceFilterLogDAO {
     List<PersonDeviceFilterLog> list();
 
     List<Map<String, Object>> unusualStatistics(@Param("temperature")BigDecimal temperature,@Param("startDate")String startDate,@Param("endDate")String endDate);
+
+    PersonDeviceFilterLog lastPersonLog(Long personId);
+
+    PersonDeviceFilterLog getByPersonIdAndDate(@Param("personId")Long personId,@Param("startDate")String startDate, @Param("endDate")String endDate);
 }

+ 4 - 0
common/src/main/java/com/jpsoft/smart/modules/base/service/PersonDeviceFilterLogService.java

@@ -38,4 +38,8 @@ public interface PersonDeviceFilterLogService {
 
     List<Map<String, Object>> unusualStatistics(BigDecimal temperature,String startDate,String endDate);
 
+    PersonDeviceFilterLog lastPersonLog(Long personId);
+
+    PersonDeviceFilterLog getByPersonIdAndDate(Long personId,String startDate,String endDate);
+
 }

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

@@ -161,6 +161,16 @@ public class PersonDeviceFilterLogServiceImpl implements PersonDeviceFilterLogSe
         return personDeviceFilterLogDAO.temperatureUnusualStatistics(temperature,startDate,endDate);
     }
 
+    @Override
+    public PersonDeviceFilterLog lastPersonLog(Long personId){
+        return personDeviceFilterLogDAO.lastPersonLog(personId);
+    }
+
+    @Override
+    public PersonDeviceFilterLog getByPersonIdAndDate(Long personId,String startDate,String endDate){
+        return personDeviceFilterLogDAO.getByPersonIdAndDate(personId,startDate,endDate);
+    }
+
 
     @Override
     public List<PersonDeviceFilterLog> list(){

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

@@ -186,5 +186,18 @@
         ]]>
         GROUP BY c.id_
     </select>
+    <select id="lastPersonLog"   resultMap="PersonDeviceFilterLogMap">
+        SELECT * FROM base_person_device_filter_log
+        WHERE del_flag = FALSE AND person_id = #{personId}
+        ORDER BY record_time desc LIMIT 1
+    </select>
+    <select id="getByPersonIdAndDate"   resultMap="PersonDeviceFilterLogMap">
+        SELECT * FROM base_person_device_filter_log
+        WHERE del_flag=FALSE AND person_id= #{personId}
+        <![CDATA[
+          AND record_time >= #{startDate} AND record_time < #{endDate}
+        ]]>
+        ORDER BY record_time desc LIMIT 1
+    </select>
 
 </mapper>

+ 1 - 1
common/src/main/resources/mapper/base/PersonInfo.xml

@@ -245,7 +245,7 @@
         left join base_company_info b on a.company_id = b.id_
         where a.open_id=#{openId} and a.del_flag = 0 limit 1
     </select>
-    <select id="findByCompanyId" resultType="com.jpsoft.smart.modules.base.entity.PersonInfo">
+    <select id="findByCompanyId" resultMap="PersonInfoMap">
         select a.* from base_person_info a
         where
         a.company_id=#{companyId} and a.del_flag = 0

+ 155 - 2
web/src/main/java/com/jpsoft/smart/modules/mobile/controller/IndividualLogApiController.java

@@ -1,12 +1,165 @@
 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;
+    }
 }