浏览代码

Merge remote-tracking branch 'origin/V1' into V1

zhengqiang 5 年之前
父节点
当前提交
a78c4918eb

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

@@ -37,5 +37,9 @@ public interface PersonDeviceFilterLogDAO {
 
     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);
+
     PersonDeviceFilterLog get(Long id);
 }

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

@@ -38,5 +38,10 @@ 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);
+
     PersonDeviceFilterLog get(Long id);
+
 }

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

@@ -166,6 +166,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

@@ -190,5 +190,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

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

@@ -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;
 
+    }
 }

+ 68 - 9
web/src/main/java/com/jpsoft/smart/modules/mobile/controller/PersonDeviceFilterLogController.java

@@ -12,20 +12,19 @@ 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 com.jpsoft.smart.modules.common.utils.PojoUtils;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.joda.time.DateTime;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.text.SimpleDateFormat;
+import java.util.*;
 
 @RestController
 @RequestMapping("/mobile/PersonDeviceFilterLog")
@@ -39,7 +38,7 @@ public class PersonDeviceFilterLogController {
     @Autowired
     private PersonInfoService personInfoService;
 
-    @ApiOperation(value="获取信息")
+    @ApiOperation(value="体温记录(正常、异常)")
     @GetMapping("edit/{id}")
     public MessageResult<PersonDeviceFilterLogDTO> edit(@PathVariable("id") Long id){
         MessageResult<PersonDeviceFilterLogDTO> msgResult = new MessageResult<>();
@@ -78,4 +77,64 @@ public class PersonDeviceFilterLogController {
 
         return msgResult;
     }
+
+    @ApiOperation(value="体温记录(个人列表)")
+    @RequestMapping(value = "list",method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "personId",value = "人员编号", required = false, paramType = "form",dataType = "Long"),
+            @ApiImplicitParam(name = "recordDate",value = "查询日期(yyyy-MM-dd)", required = false, paramType = "form",dataType = "String")
+    })
+    public MessageResult<List<PersonDeviceFilterLogDTO>> list(@RequestParam(value="personId",defaultValue="") Long personId,
+                                                              @RequestParam(value="recordDate",defaultValue="") String recordDate){
+        MessageResult<List<PersonDeviceFilterLogDTO>> msgResult = new MessageResult<>();
+
+        try {
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(sdf.parse(recordDate));
+            Date beginTime = calendar.getTime();
+            calendar.add(Calendar.DATE, 1);
+            calendar.add(Calendar.SECOND, -1);
+            Date endTime = calendar.getTime();
+
+            List<PersonDeviceFilterLogDTO> listPersonDeviceFilterLogDTO = new ArrayList<>();
+
+            Map<String,Object> searchParams = new HashMap<>();
+            searchParams.put("personId",personId);
+            searchParams.put("beginTime",beginTime);
+            searchParams.put("endTime",endTime);
+            List<Sort> sortList = new ArrayList<>();
+            sortList.add(new Sort("a.id_","asc"));
+
+            Page<PersonDeviceFilterLog> page = personDeviceFilterLogService.pageSearch(searchParams,1,1000,false, sortList);
+            for(PersonDeviceFilterLog personDeviceFilterLog : page.getResult()){
+                PersonDeviceFilterLogDTO personDeviceFilterLogDTO = new PersonDeviceFilterLogDTO();
+                PojoUtils.map(personDeviceFilterLog, personDeviceFilterLogDTO);
+
+                DeviceInfo deviceInfo = deviceInfoService.get(personDeviceFilterLog.getDeviceNo());
+                PersonInfo personInfo = personInfoService.get(Long.valueOf(personDeviceFilterLog.getPersonId()));
+
+                personDeviceFilterLogDTO.setDeviceName(deviceInfo.getAliasName());
+                personDeviceFilterLogDTO.setPersonName(personInfo.getName());
+                if(personDeviceFilterLog.getTemperature().compareTo(new BigDecimal("37")) == 1){//|| personDeviceFilterLog.getTemperature().compareTo(new BigDecimal("37")) == 0
+                    personDeviceFilterLogDTO.setFever(true);
+                }else {
+                    personDeviceFilterLogDTO.setFever(false);
+                }
+
+                listPersonDeviceFilterLogDTO.add(personDeviceFilterLogDTO);
+            }
+
+            msgResult.setResult(true);
+            msgResult.setData(listPersonDeviceFilterLogDTO);
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
 }