Selaa lähdekoodia

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

jz.kai 5 vuotta sitten
vanhempi
commit
3b8610ac99
22 muutettua tiedostoa jossa 835 lisäystä ja 212 poistoa
  1. 4 0
      common/src/main/java/com/jpsoft/smart/modules/base/dao/PersonDeviceFilterLogDAO.java
  2. 4 0
      common/src/main/java/com/jpsoft/smart/modules/base/dao/PersonInfoDAO.java
  3. 2 0
      common/src/main/java/com/jpsoft/smart/modules/base/dto/CompanyInfoDTO.java
  4. 12 0
      common/src/main/java/com/jpsoft/smart/modules/base/entity/PersonDeviceLog.java
  5. 6 1
      common/src/main/java/com/jpsoft/smart/modules/base/service/PersonDeviceFilterLogService.java
  6. 1 1
      common/src/main/java/com/jpsoft/smart/modules/base/service/PersonDeviceLogService.java
  7. 4 0
      common/src/main/java/com/jpsoft/smart/modules/base/service/PersonInfoService.java
  8. 26 8
      common/src/main/java/com/jpsoft/smart/modules/base/service/impl/PersonDeviceFilterLogServiceImpl.java
  9. 18 5
      common/src/main/java/com/jpsoft/smart/modules/base/service/impl/PersonDeviceLogServiceImpl.java
  10. 48 0
      common/src/main/java/com/jpsoft/smart/modules/base/service/impl/PersonInfoServiceImpl.java
  11. 83 77
      common/src/main/java/com/jpsoft/smart/modules/common/utils/LApiUtil.java
  12. 5 2
      common/src/main/resources/mapper/base/CompanyInfo.xml
  13. 137 84
      common/src/main/resources/mapper/base/PersonDeviceFilterLog.xml
  14. 7 1
      common/src/main/resources/mapper/base/PersonDeviceLog.xml
  15. 52 3
      common/src/main/resources/mapper/base/PersonDeviceRelation.xml
  16. 19 0
      common/src/main/resources/mapper/base/PersonInfo.xml
  17. 13 6
      lapi/src/main/java/com/jpsoft/smart/lapi/handler/PersonVerificationHandler.java
  18. 2 2
      web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonDeviceLogController.java
  19. 288 0
      web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonDeviceRelationController.java
  20. 43 12
      web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonInfoController.java
  21. 23 5
      web/src/main/java/com/jpsoft/smart/modules/base/controller/ReportController.java
  22. 38 5
      web/src/main/java/com/jpsoft/smart/modules/mobile/controller/PersonDeviceLogApiController.java

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

@@ -66,4 +66,8 @@ public interface PersonDeviceFilterLogDAO {
     int deleteExpiredVisitorRecord(@Param("limit") int limit);
 
     List<PersonDeviceFilterLog> getDayCheckedPersonByCompanyList(@Param("startDate") Date startDate, @Param("endDate") Date endDate, @Param("companyInfo") CompanyInfo companyInfo);
+
+    long countDetectedByCompanyIds(List<String> companyIds, Date startTime, Date endTime);
+
+    List<PersonInfo> findUndetectedPersonListByCompanyIds(Map<String, Object> searchParams);
 }

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

@@ -35,4 +35,8 @@ public interface PersonInfoDAO {
 	PersonInfo findById(long id);
 
     long countByCompanyId(String companyId);
+
+    long countByCompanyIds(List<String> companyIds);
+
+    PersonInfo findByIdCardAndCompanyId(String idCard,String companyId);
 }

+ 2 - 0
common/src/main/java/com/jpsoft/smart/modules/base/dto/CompanyInfoDTO.java

@@ -1,12 +1,14 @@
 package com.jpsoft.smart.modules.base.dto;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.jpsoft.smart.modules.base.entity.CompanyInfo;
 import com.jpsoft.smart.modules.base.entity.CompanyPosition;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import org.springframework.format.annotation.DateTimeFormat;
 
 import java.util.Date;
+import java.util.List;
 
 @Data
 public class CompanyInfoDTO {

+ 12 - 0
common/src/main/java/com/jpsoft/smart/modules/base/entity/PersonDeviceLog.java

@@ -40,6 +40,12 @@ public class PersonDeviceLog {
     @ApiModelProperty(value = "人员id")
     private Integer personId;
 
+    /**
+     * 人员姓名
+     */
+    @ApiModelProperty(value = "人员姓名")
+    private String personName;
+
     @ApiModelProperty(value = "人员信息")
     private PersonInfo person;
 
@@ -49,6 +55,12 @@ public class PersonDeviceLog {
     @ApiModelProperty(value = "记录温度")
     private BigDecimal temperature;
 
+    /**
+     * 验证号码
+     */
+    @ApiModelProperty(value = "验证号码")
+    private String identityNo;
+
 
     /**
      * 匹配状态

+ 6 - 1
common/src/main/java/com/jpsoft/smart/modules/base/service/PersonDeviceFilterLogService.java

@@ -28,7 +28,7 @@ public interface PersonDeviceFilterLogService {
      * @param libMatInfoListJson
      * @param matchPersonInfo
      */
-    void deviceInsertFilterLog(String deviceNo, BigDecimal temperature, JSONObject faceImageJson, JSONObject libMatInfoListJson, JSONObject matchPersonInfo, Date date);
+    void deviceInsertFilterLog(String deviceNo, BigDecimal temperature, JSONObject faceImageJson, JSONObject libMatInfoListJson, JSONObject matchPersonInfo, Date date,Integer maskFlag);
 
     Page<PersonDeviceFilterLog> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize, boolean count, List<Sort> sortList);
 
@@ -80,4 +80,9 @@ public interface PersonDeviceFilterLogService {
     int deleteExpiredVisitorRecord(int limit);
 
     List<PersonDeviceFilterLog> getDayCheckedPersonByCompanyList(Date beginTime, Date endTime,CompanyInfo companyInfo);
+
+    long countDetectedByCompanyIds(List<String> companyIds, Date startTime, Date endTime);
+
+
+    Page<PersonInfo> findUndetectedPersonListByCompanyIds(Map<String, Object> searchParams, int pageIndex, int pageSize, boolean b);
 }

+ 1 - 1
common/src/main/java/com/jpsoft/smart/modules/base/service/PersonDeviceLogService.java

@@ -29,7 +29,7 @@ public interface PersonDeviceLogService {
      * @param libMatInfoListJson
      * @param matchPersonInfo
      */
-    void deviceInsertLog(String deviceNo, BigDecimal temperature, JSONObject faceImageJson, JSONObject libMatInfoListJson, JSONObject matchPersonInfo, Date date);
+    void deviceInsertLog(String deviceNo, BigDecimal temperature, JSONObject faceImageJson, JSONObject libMatInfoListJson, JSONObject matchPersonInfo, Date date,Integer maskFlag);
     Page<PersonDeviceLog> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize,boolean count, List<Sort> sortList);
     List<PersonDeviceLog> findByPersonAndDate(Long personId,Date startDate,Date endDate);
     Page<PersonDeviceLog> simplePageSearch(Map<String, Object> searchParams, int pageNum, int pageSize,boolean count, List<Sort> sortList);

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

@@ -34,4 +34,8 @@ public interface PersonInfoService {
 	PersonInfo findById(long longValue);
 
     long countByCompanyId(String companyId);
+
+    long countByCompanyIds(List<String> companyIds);
+
+    PersonInfo addPersonForCompany(PersonInfo personInfo, String deviceNo);
 }

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

@@ -61,7 +61,7 @@ public class PersonDeviceFilterLogServiceImpl implements PersonDeviceFilterLogSe
     }
 
     @Override
-    public void deviceInsertFilterLog(String deviceNo, BigDecimal temperature, JSONObject faceImageJson, JSONObject libMatInfoListJson, JSONObject matchPersonInfo, Date date) {
+    public void deviceInsertFilterLog(String deviceNo, BigDecimal temperature, JSONObject faceImageJson, JSONObject libMatInfoListJson, JSONObject matchPersonInfo, Date date,Integer maskFlag) {
 
         try {
 
@@ -90,11 +90,15 @@ public class PersonDeviceFilterLogServiceImpl implements PersonDeviceFilterLogSe
             //记录的时间段
             String recordTimeZons = DateUtil.format(date, "yyyy-MM-dd-HH-mm");
             String timeZones = TimeZonesUtil.getUpperTimeZone(recordTimeZons);
-            Integer personId = LApiUtil.getPersonCode(libMatInfoListJson, matchPersonInfo);
-            if (personId != 0 && temperature.compareTo(BigDecimal.ZERO) == 1) {
+            PersonInfo personInfo = LApiUtil.getPersonCode(libMatInfoListJson, matchPersonInfo);
 
+            PersonInfo personInfoReturn = personInfoService.addPersonForCompany(personInfo,deviceNo);
+           // Integer personId = LApiUtil.getPersonCode(libMatInfoListJson, matchPersonInfo);
+            LApiUtil lApiUtil = new LApiUtil();
+            if (personInfoReturn.getId() != 0L && temperature.compareTo(BigDecimal.ZERO) == 1) {
 
-                PersonDeviceFilterLog personDeviceFilterLog = personDeviceFilterLogDAO.findByPersonIdAndDeviceNoAndTimeZones(personId, deviceNo, timeZones);
+
+                PersonDeviceFilterLog personDeviceFilterLog = personDeviceFilterLogDAO.findByPersonIdAndDeviceNoAndTimeZones(Math.toIntExact(personInfoReturn.getId()), deviceNo, timeZones);
 
                 if (personDeviceFilterLog != null) {
                     BigDecimal oldTemper = personDeviceFilterLog.getTemperature();
@@ -106,7 +110,7 @@ public class PersonDeviceFilterLogServiceImpl implements PersonDeviceFilterLogSe
 
                     if (StringUtils.isNotBlank(libMatInfoListJson.getStr("MatchStatus"))) {
                         personDeviceFilterLog.setMatchStatus(libMatInfoListJson.getInt("MatchStatus"));
-                        personDeviceFilterLog.setMatchMsg(LApiUtil.getMatchMsg(libMatInfoListJson.getInt("MatchStatus")));
+                        personDeviceFilterLog.setMatchMsg(lApiUtil.getMatchMsg(libMatInfoListJson.getInt("MatchStatus"),maskFlag,temperature,temperatureConfig));
                         personDeviceFilterLog.setMatchFaceId(libMatInfoListJson.getInt("MatchFaceID"));
                     } else {
                         personDeviceFilterLog.setMatchStatus(0);
@@ -126,11 +130,11 @@ public class PersonDeviceFilterLogServiceImpl implements PersonDeviceFilterLogSe
                 } else {
                     PersonDeviceFilterLog personDeviceFilterLog1 = new PersonDeviceFilterLog();
                     personDeviceFilterLog1.setDeviceNo(deviceNo);
-                    personDeviceFilterLog1.setPersonId(personId);
+                    personDeviceFilterLog1.setPersonId(Math.toIntExact(personInfoReturn.getId()));
                     personDeviceFilterLog1.setTemperature(temperature);
                     if (StringUtils.isNotBlank(libMatInfoListJson.getStr("MatchStatus"))) {
                         personDeviceFilterLog1.setMatchStatus(libMatInfoListJson.getInt("MatchStatus"));
-                        personDeviceFilterLog1.setMatchMsg(LApiUtil.getMatchMsg(libMatInfoListJson.getInt("MatchStatus")));
+                        personDeviceFilterLog1.setMatchMsg(lApiUtil.getMatchMsg(libMatInfoListJson.getInt("MatchStatus"),maskFlag,temperature,temperatureConfig));
                         personDeviceFilterLog1.setMatchFaceId(libMatInfoListJson.getInt("MatchFaceID"));
                     } else {
                         personDeviceFilterLog1.setMatchStatus(0);
@@ -147,7 +151,7 @@ public class PersonDeviceFilterLogServiceImpl implements PersonDeviceFilterLogSe
 
                 new Thread(() -> {
                     try {
-                        addCheckNumForCompany(personId, temperature, date);
+                        addCheckNumForCompany(Math.toIntExact(personInfoReturn.getId()), temperature, date);
                     } catch (Exception e) {
                         log.error(e.getMessage(), e);
                     }
@@ -293,4 +297,18 @@ public class PersonDeviceFilterLogServiceImpl implements PersonDeviceFilterLogSe
     public List<PersonDeviceFilterLog> getDayCheckedPersonByCompanyList(Date beginTime, Date endTime, CompanyInfo companyInfo) {
         return personDeviceFilterLogDAO.getDayCheckedPersonByCompanyList(beginTime,endTime,companyInfo);
     }
+
+    @Override
+    public long countDetectedByCompanyIds(List<String> companyIds, Date startTime, Date endTime) {
+        return personDeviceFilterLogDAO.countDetectedByCompanyIds(companyIds,  startTime, endTime);
+    }
+
+    @Override
+    public Page<PersonInfo> findUndetectedPersonListByCompanyIds(Map<String, Object> searchParams, int pageIndex, int pageSize, boolean count) {
+        Page<PersonInfo> page = PageHelper.startPage(pageIndex,pageSize,count).doSelectPage(()->{
+            personDeviceFilterLogDAO.findUndetectedPersonListByCompanyIds(searchParams);
+        });
+
+        return page;
+    }
 }

+ 18 - 5
common/src/main/java/com/jpsoft/smart/modules/base/service/impl/PersonDeviceLogServiceImpl.java

@@ -5,10 +5,12 @@ import cn.hutool.json.JSONObject;
 import com.github.pagehelper.Page;
 import com.github.pagehelper.PageHelper;
 import com.jpsoft.smart.config.OSSConfig;
+import com.jpsoft.smart.config.TemperatureConfig;
 import com.jpsoft.smart.config.WxConfig;
 import com.jpsoft.smart.modules.base.dao.*;
 import com.jpsoft.smart.modules.base.entity.*;
 import com.jpsoft.smart.modules.base.service.PersonDeviceLogService;
+import com.jpsoft.smart.modules.base.service.PersonInfoService;
 import com.jpsoft.smart.modules.base.service.WarningPusherService;
 import com.jpsoft.smart.modules.common.dto.Sort;
 import com.jpsoft.smart.modules.common.utils.*;
@@ -45,9 +47,14 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
     @Autowired
     private WxConfig wxConfig;
 
+    @Autowired
+    private TemperatureConfig temperatureConfig;
+
     @Autowired
     private WarningPusherService warningPusherService;
 
+    @Autowired
+    private PersonInfoService personInfoService;
 
     @Resource(name = "personDeviceLogDAO")
     private PersonDeviceLogDAO personDeviceLogDAO;
@@ -63,7 +70,7 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
 
 
     @Override
-    public void deviceInsertLog(String deviceNo, BigDecimal temperature, JSONObject faceImageJson, JSONObject libMatInfoListJson, JSONObject matchPersonInfo, Date date) {
+    public void deviceInsertLog(String deviceNo, BigDecimal temperature, JSONObject faceImageJson, JSONObject libMatInfoListJson, JSONObject matchPersonInfo, Date date,Integer maskFlag) {
         String retFileUrl = "";
         try {
 
@@ -85,17 +92,23 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
             log.error("保存图片路径错误" + e.getMessage());
         }
 
-        Integer personId = LApiUtil.getPersonCode(libMatInfoListJson, matchPersonInfo);
+        PersonInfo personInfo = LApiUtil.getPersonCode(libMatInfoListJson, matchPersonInfo);
+
+        PersonInfo peronInfoReturn = personInfoService.addPersonForCompany(personInfo,deviceNo);
+      //  Integer personId = LApiUtil.getPersonCode(libMatInfoListJson, matchPersonInfo);
 
         PersonDeviceLog personDeviceLog = new PersonDeviceLog();
         personDeviceLog.setId(UUID.randomUUID().toString());
         personDeviceLog.setDeviceNo(deviceNo);
-        personDeviceLog.setPersonId(personId);
+        personDeviceLog.setPersonId(Math.toIntExact(peronInfoReturn.getId()));
+        personDeviceLog.setPersonName(personInfo.getName());
+        personDeviceLog.setIdentityNo(personInfo.getIdCard());
 
         personDeviceLog.setTemperature(temperature);
+        LApiUtil lApiUtil = new LApiUtil();
         if (StringUtils.isNotBlank(libMatInfoListJson.getStr("MatchStatus"))) {
             personDeviceLog.setMatchStatus(libMatInfoListJson.getInt("MatchStatus"));
-            personDeviceLog.setMatchMsg(LApiUtil.getMatchMsg(libMatInfoListJson.getInt("MatchStatus")));
+            personDeviceLog.setMatchMsg(lApiUtil.getMatchMsg(libMatInfoListJson.getInt("MatchStatus"),maskFlag,temperature,temperatureConfig));
             personDeviceLog.setMatchFaceId(libMatInfoListJson.getInt("MatchFaceID"));
         } else {
             personDeviceLog.setMatchStatus(0);
@@ -111,7 +124,7 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
         //人员识别成功,温度超过限定时发送模板消息给监管者
         new Thread(()->{
             try {
-                if (personId != 0) {
+                if (personInfo.getId() != 0L) {
                     sendTemperatureAlarmsyncTask(personDeviceLog);
                 }
             }

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

@@ -1,11 +1,16 @@
 package com.jpsoft.smart.modules.base.service.impl;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 import javax.annotation.Resource;
 
 import com.jpsoft.smart.modules.base.entity.CompanyInfo;
+import com.jpsoft.smart.modules.base.entity.DeviceInfo;
+import com.jpsoft.smart.modules.base.service.DeviceInfoService;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
 import com.jpsoft.smart.modules.base.dao.PersonInfoDAO;
@@ -21,6 +26,9 @@ public class PersonInfoServiceImpl implements PersonInfoService {
 	@Resource(name="personInfoDAO")
 	private PersonInfoDAO personInfoDAO;
 
+	@Autowired
+	private DeviceInfoService deviceInfoService;
+
 	@Override
 	public PersonInfo get(Long id) {
 		// TODO Auto-generated method stub
@@ -125,4 +133,44 @@ public class PersonInfoServiceImpl implements PersonInfoService {
 	public long countByCompanyId(String companyId) {
 		return personInfoDAO.countByCompanyId(companyId);
 	}
+
+	@Override
+	public long countByCompanyIds(List<String> companyIds) {
+		return personInfoDAO.countByCompanyIds(companyIds);
+	}
+
+	@Override
+	public PersonInfo addPersonForCompany(PersonInfo personInfo, String deviceNo) {
+
+		if (StringUtils.isNotBlank(personInfo.getName()) && StringUtils.isNotBlank(personInfo.getIdCard()) && personInfo.getId()==0){
+			DeviceInfo deviceInfo = deviceInfoService.getByDeviceNo(deviceNo);
+			if (deviceInfo!=null){
+				PersonInfo personInfo1 = personInfoDAO.findByIdCardAndCompanyId(personInfo.getIdCard(),deviceInfo.getCompanyId());
+				if (personInfo1 == null){
+					PersonInfo personInfo2 = new PersonInfo();
+					personInfo2.setCompanyId(deviceInfo.getCompanyId());
+					personInfo2.setName(personInfo.getName());
+					personInfo2.setIdCard(personInfo.getIdCard());
+					personInfo2.setDelFlag(false);
+					personInfo2.setCreateTime(new Date());
+					personInfo2.setPopedom("1");
+					personInfo2.setWechatNoticeEnabled(false);
+					personInfo2.setAllowViewLocal(false);
+					personInfoDAO.insert(personInfo2);
+					return personInfo2;
+				}else {
+					return personInfo1;
+				}
+
+
+			}else {
+				return personInfo;
+			}
+
+
+		}
+		else {
+			return personInfo;
+		}
+	}
 }

+ 83 - 77
common/src/main/java/com/jpsoft/smart/modules/common/utils/LApiUtil.java

@@ -2,6 +2,9 @@ package com.jpsoft.smart.modules.common.utils;
 
 import cn.hutool.http.HttpRequest;
 import com.alibaba.fastjson.JSONObject;
+import com.jpsoft.smart.config.TemperatureConfig;
+import com.jpsoft.smart.modules.base.entity.PersonInfo;
+import com.jpsoft.smart.modules.base.service.PersonInfoService;
 import com.jpsoft.smart.modules.lapi.channel.LapiChannel;
 import io.netty.handler.codec.http.DefaultHttpRequest;
 import io.netty.handler.codec.http.HttpMethod;
@@ -10,6 +13,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
+
 import java.math.BigDecimal;
 import java.util.HashMap;
 import java.util.Map;
@@ -22,9 +26,13 @@ import java.util.concurrent.TimeUnit;
 @Slf4j
 @Component
 public class LApiUtil {
-    private final static int TIMEOUT = 10*1000;
+    private final static int TIMEOUT = 10 * 1000;
+
+    @Autowired
+    private PersonInfoService personInfoService;
+
 
-    public static JSONObject postRequest(String url, HashMap map){
+    public static JSONObject postRequest(String url, HashMap map) {
         String body = HttpRequest.post(url)
                 .timeout(TIMEOUT)
                 .body(new JSONObject(map).toJSONString()).execute().body();
@@ -32,7 +40,7 @@ public class LApiUtil {
         return jsonbody;
     }
 
-    public static JSONObject getRequest(String url) throws Exception{
+    public static JSONObject getRequest(String url) throws Exception {
         String body = HttpRequest.get(url)
                 .timeout(TIMEOUT)
                 .execute().body();
@@ -42,14 +50,14 @@ public class LApiUtil {
     }
 
     public static JSONObject deleteRequest(String url) {
-       String body = HttpRequest.delete(url)
-               .timeout(TIMEOUT)
-               .execute().body();
-       JSONObject jsonbody = JSONObject.parseObject(body);
-       return jsonbody;
+        String body = HttpRequest.delete(url)
+                .timeout(TIMEOUT)
+                .execute().body();
+        JSONObject jsonbody = JSONObject.parseObject(body);
+        return jsonbody;
     }
 
-    public static JSONObject putRequest(String url){
+    public static JSONObject putRequest(String url) {
         String body = HttpRequest.put(url)
                 .timeout(TIMEOUT)
                 .execute().body();
@@ -58,7 +66,7 @@ public class LApiUtil {
         return jsonbody;
     }
 
-    public static JSONObject putRequest(String url,HashMap map){
+    public static JSONObject putRequest(String url, HashMap map) {
         String body = HttpRequest.put(url)
                 .timeout(TIMEOUT)
                 .body(new JSONObject(map).toJSONString()).execute().body();
@@ -67,145 +75,143 @@ public class LApiUtil {
         return jsonbody;
     }
 
-    public static JSONObject getResponse(JSONObject dataJson) throws Exception{
-        if (dataJson.getInteger("ResponseCode") == 1){
+    public static JSONObject getResponse(JSONObject dataJson) throws Exception {
+        if (dataJson.getInteger("ResponseCode") == 1) {
             throw new Exception("通用错误");
         }
-        if (dataJson.getInteger("ResponseCode") == 2){
+        if (dataJson.getInteger("ResponseCode") == 2) {
             throw new Exception("参数非法");
         }
-        if (dataJson.getInteger("ResponseCode") == 3){
+        if (dataJson.getInteger("ResponseCode") == 3) {
             throw new Exception("用户无权限");
         }
-        if (dataJson.getInteger("ResponseCode") == 4){
+        if (dataJson.getInteger("ResponseCode") == 4) {
             throw new Exception("设备不支持");
         }
-        if (dataJson.getInteger("ResponseCode") == 5){
+        if (dataJson.getInteger("ResponseCode") == 5) {
             throw new Exception("用户状态异常");
         }
-        if (dataJson.getInteger("StatusCode") == 1){
+        if (dataJson.getInteger("StatusCode") == 1) {
             throw new Exception("执行失败");
         }
-        if (dataJson.getInteger("StatusCode") == 2){
+        if (dataJson.getInteger("StatusCode") == 2) {
             throw new Exception("输入参数非法");
         }
-        if (dataJson.getInteger("StatusCode") == 3){
+        if (dataJson.getInteger("StatusCode") == 3) {
             throw new Exception("系统内存不足");
         }
-        if (dataJson.getInteger("StatusCode") == 8){
+        if (dataJson.getInteger("StatusCode") == 8) {
             throw new Exception("功能不支持");
         }
-        if (dataJson.getInteger("StatusCode") == 10){
+        if (dataJson.getInteger("StatusCode") == 10) {
             throw new Exception("序列化执行失败");
         }
-        if (dataJson.getInteger("StatusCode") == 11){
+        if (dataJson.getInteger("StatusCode") == 11) {
             throw new Exception("Basic 鉴权失败");
         }
-        if (dataJson.getInteger("StatusCode") == 12){
+        if (dataJson.getInteger("StatusCode") == 12) {
             throw new Exception("Digest 鉴权失败");
         }
-        if (dataJson.getInteger("StatusCode") == 13){
+        if (dataJson.getInteger("StatusCode") == 13) {
             throw new Exception("订阅已满");
         }
-        if (dataJson.getInteger("StatusCode") == 14){
+        if (dataJson.getInteger("StatusCode") == 14) {
             throw new Exception("重复订阅");
         }
 
         return dataJson.getJSONObject("Data");
     }
 
-    public static String getMatchMsg(Integer matchStatus){
+    public String getMatchMsg(Integer matchStatus, Integer maskFlag, BigDecimal temperature, TemperatureConfig temperatureConfig) {
         String matchMsg = "";
-        if (matchStatus ==1){
+        if (matchStatus == 1) {
             matchMsg = "核验成功";
-        }
-        else if (matchStatus == 2){
+        } else if (matchStatus == 2) {
             matchMsg = "对比失败";
-        }
-        else if (matchStatus == 3){
+        } else if (matchStatus == 3) {
             matchMsg = "对比成功,不在布控时间";
-        }
-        else if (matchStatus == 7){
+        } else if (matchStatus == 7) {
             matchMsg = "刷脸开门模式下,刷脸成功";
-        }
+        } else if (matchStatus == 10) {
+            if (temperature.compareTo(new BigDecimal(temperatureConfig.getMax())) == 1) {
+                matchMsg = "对比成功,体温异常";
+            } else if (maskFlag == 1) {
+                matchMsg = "对比成功,未戴口罩";
+            } else {
+                matchMsg = "对比成功,人脸属性异常";
+            }
 
-        else if (matchStatus == 10){
-            matchMsg = "对比成功,人脸属性异常";
-        }
-        else {
+        } else {
             matchMsg = "未知匹配消息";
         }
 
         return matchMsg;
     }
 
-    public static Integer imageSize(String imageBase64Str){
+    public static Integer imageSize(String imageBase64Str) {
 
         //1.找到等号,把等号也去掉(=用来填充base64字符串长度用)
-        Integer equalIndex= imageBase64Str.indexOf("=");
-        if(imageBase64Str.indexOf("=")>0) {
-            imageBase64Str=imageBase64Str.substring(0, equalIndex);
+        Integer equalIndex = imageBase64Str.indexOf("=");
+        if (imageBase64Str.indexOf("=") > 0) {
+            imageBase64Str = imageBase64Str.substring(0, equalIndex);
         }
         //2.原来的字符流大小,单位为字节
-        Integer strLength=imageBase64Str.length();
-     //   System.out.println("imageBase64Str Length = "+strLength);
+        Integer strLength = imageBase64Str.length();
+        //   System.out.println("imageBase64Str Length = "+strLength);
         //3.计算后得到的文件流大小,单位为字节
-        Integer size=strLength-(strLength/8)*2;
+        Integer size = strLength - (strLength / 8) * 2;
         return size;
     }
 
-    public static Integer getPersonCode(cn.hutool.json.JSONObject libMatInfoListJson, cn.hutool.json.JSONObject matchPersonInfo){
-        if (org.apache.commons.lang.StringUtils.isNotBlank(libMatInfoListJson.getStr("MatchPersonID"))){
-            if (!libMatInfoListJson.getStr("MatchPersonID").equals("0") && org.apache.commons.lang3.StringUtils.isNotBlank(matchPersonInfo.getStr("PersonCode"))){
-                return matchPersonInfo.getInt("PersonCode");
-
-            }else if (!libMatInfoListJson.getStr("MatchPersonID").equals("0") && org.apache.commons.lang3.StringUtils.isBlank(matchPersonInfo.getStr("PersonCode")) && StringUtils.isNotBlank(matchPersonInfo.getStr("PersonName"))){
-                String personName = matchPersonInfo.getStr("PersonName");
-                if (personName.contains("_")){
-                    log.warn(personName+"校验成功但未找到personCode");
-                    Integer personId =Integer.valueOf(personName.substring(personName.indexOf("_")+1)) ;
-                    return personId;
-                }else {
-                    log.warn(personName+"校验成功但姓名中无personCode后缀");
-                    return 0;
-                }
+    public static PersonInfo getPersonCode(cn.hutool.json.JSONObject libMatInfoListJson, cn.hutool.json.JSONObject matchPersonInfo) {
+        PersonInfo personInfo = new PersonInfo();
+        String personName = "";
+        Long personId = 0L;
+        String identityNo = "";
+        if (org.apache.commons.lang.StringUtils.isNotBlank(libMatInfoListJson.getStr("MatchPersonID"))) {
+            personName = matchPersonInfo.getStr("PersonName");
+            personId = libMatInfoListJson.getLong("MatchPersonID");
+            identityNo = matchPersonInfo.getStr("IdentityNo");
+            if (personName.contains("_")) {
+                personId = Long.valueOf(personName.substring(personName.indexOf("_") + 1));
+                personName = personName.substring(0, personName.indexOf("_"));
 
 
             }
 
-            else {
-                return 0;
-            }
-        }else {
-            return 0;
+
         }
 
 
+        personInfo.setId(personId);
+        personInfo.setName(personName);
+        personInfo.setIdCard(identityNo);
+        return personInfo;
+
+
     }
 
-    public static boolean compareToInterval(BigDecimal bigDecimal, float min,float max){
-        if (bigDecimal.compareTo(new BigDecimal(min))==-1 || bigDecimal.compareTo(new BigDecimal(max)) ==1){
+    public static boolean compareToInterval(BigDecimal bigDecimal, float min, float max) {
+        if (bigDecimal.compareTo(new BigDecimal(min)) == -1 || bigDecimal.compareTo(new BigDecimal(max)) == 1) {
             return false;
-        }
-        else {
+        } else {
             return true;
         }
 
     }
 
 
-
     public static void main(String[] args) {
-     //   Date date = new Date(1584405803000L);
-    //    Date date = new
-     //   Date date = new Date();
-      // long time = date.getTime();
-     //   System.out.println(date);
-      //  192.168.11.13:80/V1.0/PeopleLibraries/1584409665/People/1111?LastChange=1584428390872
+        //   Date date = new Date(1584405803000L);
+        //    Date date = new
+        //   Date date = new Date();
+        // long time = date.getTime();
+        //   System.out.println(date);
+        //  192.168.11.13:80/V1.0/PeopleLibraries/1584409665/People/1111?LastChange=1584428390872
 //        cn.hutool.json.JSONObject jsonObject = new cn.hutool.json.JSONObject();
 //        Integer integer = getPersonCode(jsonObject,jsonObject);
 //        System.out.println(integer);
-        Map<String,Object> map = new HashMap<>();
+        Map<String, Object> map = new HashMap<>();
 
 //        String requestStr = HttpRequest.post("http://www.baidu.com")
 //                .timeout(TIMEOUT)

+ 5 - 2
common/src/main/resources/mapper/base/CompanyInfo.xml

@@ -118,7 +118,7 @@
         select count(*) from base_company_info where id_=#{0} and del_flag = 0
     </select>
     <select id="list" resultMap="CompanyInfoMap">
-        select * from base_company_info where del_flag=0 order by sort_no asc
+        select * from base_company_info where del_flag=0 order by code_ asc,sort_no asc
     </select>
     <select id="search" parameterType="hashmap" resultMap="CompanyInfoMap">
         <![CDATA[
@@ -152,13 +152,16 @@
             <if test="code!=null">
                 a.code_ like #{code}
             </if>
+            <if test="code==null">
+                a.code_='-1'
+            </if>
             <if test="personId!=null">
                 or a.id_ in (
                     select c.company_id from base_person_company c where c.person_id = #{personId}
                 )
             </if>
         </trim>
-        order by a.sort_no asc,a.name_ asc
+        order by a.code_ asc,a.sort_no asc,a.name_ asc
     </select>
     <select id="countByParentId" resultType="long">
         select count(*) from base_company_info

+ 137 - 84
common/src/main/resources/mapper/base/PersonDeviceFilterLog.xml

@@ -20,28 +20,30 @@
     </sql>
     <delete id="deleteExpiredVisitorRecord">
         <![CDATA[
-            delete from base_person_device_filter_log
-            where datediff(now(),record_time)>1
-            and person_id=0
-            order by record_time asc limit ${limit}
+
+                    delete from base_person_device_filter_log
+                    where datediff(now(),record_time)>1
+                    and person_id=0
+                    order by record_time asc limit ${limit}
+
         ]]>
     </delete>
     <resultMap id="PersonDeviceFilterLogMap" type="com.jpsoft.smart.modules.base.entity.PersonDeviceFilterLog">
-        <id property="id" column="id_" />
-        <result property="createBy" column="create_by" />
-        <result property="createTime" column="create_time" />
-        <result property="updateBy" column="update_by" />
-        <result property="updateTime" column="update_time" />
-        <result property="delFlag" column="del_flag" />
-        <result property="deviceNo" column="device_no" />
-        <result property="personId" column="person_id" />
-        <result property="temperature" column="temperature_" />
-        <result property="matchStatus" column="match_status" />
-        <result property="matchMsg" column="match_msg" />
-        <result property="matchFaceId" column="match_face_id" />
-        <result property="faceImage" column="face_image" />
-        <result property="recordTime" column="record_time" />
-        <result property="timeZones" column="time_zones" />
+        <id property="id" column="id_"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="delFlag" column="del_flag"/>
+        <result property="deviceNo" column="device_no"/>
+        <result property="personId" column="person_id"/>
+        <result property="temperature" column="temperature_"/>
+        <result property="matchStatus" column="match_status"/>
+        <result property="matchMsg" column="match_msg"/>
+        <result property="matchFaceId" column="match_face_id"/>
+        <result property="faceImage" column="face_image"/>
+        <result property="recordTime" column="record_time"/>
+        <result property="timeZones" column="time_zones"/>
     </resultMap>
 
     <select id="get" parameterType="long" resultMap="PersonDeviceFilterLogMap">
@@ -184,38 +186,42 @@
                 ]]>
             </if>
         </where>
-        <foreach item="sort" collection="sortList"  open="order by" separator=",">
+        <foreach item="sort" collection="sortList" open="order by" separator=",">
             ${sort.name} ${sort.order}
         </foreach>
     </select>
-    <select id="temperatureNormalStatistics"   resultMap="PersonDeviceFilterLogMap">
+    <select id="temperatureNormalStatistics" resultMap="PersonDeviceFilterLogMap">
         <![CDATA[
-            select count(*) from base_person_device_filter_log a
-            LEFT JOIN base_person_info b on a.person_id=b.id_
-            LEFT JOIN base_company_info c on b.company_id=c.id_
-            where a.del_flag=false
-            and c.code_ like #{companyCode}
-            and a.temperature_ < #{temperature}
-            and a.record_time >= #{startDate}
-            and a.record_time <= #{endDate}
+
+                    select count(*) from base_person_device_filter_log a
+                    LEFT JOIN base_person_info b on a.person_id=b.id_
+                    LEFT JOIN base_company_info c on b.company_id=c.id_
+                    where a.del_flag=false
+                    and c.code_ like #{companyCode}
+                    and a.temperature_ < #{temperature}
+                    and a.record_time >= #{startDate}
+                    and a.record_time <= #{endDate}
+
         ]]>
     </select>
-    <select id="temperatureUnusualStatistics"   resultMap="PersonDeviceFilterLogMap">
+    <select id="temperatureUnusualStatistics" resultMap="PersonDeviceFilterLogMap">
         <![CDATA[
-            select count(*) from base_person_device_filter_log a
-            LEFT JOIN base_person_info b on a.person_id=b.id_
-            LEFT JOIN base_company_info c on b.company_id=c.id_
-            where a.del_flag=false
-            and c.code_ like #{companyCode}
-            and a.temperature_ >= #{temperature}
-            and a.record_time >= #{startDate}
-            and a.record_time <= #{endDate}
+
+                    select count(*) from base_person_device_filter_log a
+                    LEFT JOIN base_person_info b on a.person_id=b.id_
+                    LEFT JOIN base_company_info c on b.company_id=c.id_
+                    where a.del_flag=false
+                    and c.code_ like #{companyCode}
+                    and a.temperature_ >= #{temperature}
+                    and a.record_time >= #{startDate}
+                    and a.record_time <= #{endDate}
+
         ]]>
     </select>
     <select id="list" resultMap="PersonDeviceFilterLogMap">
         select * from base_person_device_filter_log where del_flag=false
     </select>
-    <select id="unusualStatistics"   resultType="java.util.HashMap">
+    <select id="unusualStatistics" resultType="java.util.HashMap">
         <![CDATA[
         select
         c.id_ as id,
@@ -232,21 +238,21 @@
             and a.record_time < #{endDate}
         ]]>
         and (
-            c.code_ like #{companyCode}
+        c.code_ like #{companyCode}
         <if test="personId!=null">
             or c.id_ in (
-                select d.company_id from base_person_company d where d.person_id = #{personId}
+            select d.company_id from base_person_company d where d.person_id = #{personId}
             )
         </if>
         )
         GROUP BY c.id_,date_format(a.record_time,'%Y-%m-%d')
     </select>
-    <select id="lastPersonLog"   resultMap="PersonDeviceFilterLogMap">
+    <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 id="getByPersonIdAndDate" resultMap="PersonDeviceFilterLogMap">
         SELECT * FROM base_person_device_filter_log
         WHERE del_flag=FALSE AND person_id= #{personId}
         <![CDATA[
@@ -267,17 +273,17 @@
         c.code_ like #{companyCode}
         <if test="personId!=null">
             or c.id_ in (
-                select d.company_id from base_person_company d where d.person_id = #{personId}
+            select d.company_id from base_person_company d where d.person_id = #{personId}
             )
         </if>
         )
         <if test="status==1">
-        <![CDATA[
+            <![CDATA[
             and a.temperature_<=#{temperatureMax}
         ]]>
         </if>
         <if test="status==-1">
-        <![CDATA[
+            <![CDATA[
             and a.temperature_>#{temperatureMax}
         ]]>
         </if>
@@ -295,14 +301,15 @@
             )
         ]]>
         and (
-            b.code_ like #{companyCode}
-<!--        <if test="personId!=null">
-            or b.id_ in (
-                select d.company_id from base_person_company d where d.person_id = #{personId}
-            )
-        </if>-->
+        b.code_ like #{companyCode}
+        <!--        <if test="personId!=null">
+                    or b.id_ in (
+                        select d.company_id from base_person_company d where d.person_id = #{personId}
+                    )
+                </if>-->
         <if test="personCompanyList!=null">
-            <foreach collection="personCompanyList" index="index" item="item" open=" or b.id_ in(" separator="," close=")">
+            <foreach collection="personCompanyList" index="index" item="item" open=" or b.id_ in(" separator=","
+                     close=")">
                 #{item.companyId}
             </foreach>
         </if>
@@ -310,10 +317,12 @@
     </select>
     <select id="getDayAbnormalNum" resultType="java.lang.Integer">
         <![CDATA[
-            select count(DISTINCT person_id) from base_person_device_filter_log
-            where record_time >=#{startTime}
-            and record_time <= #{endTime}
-            and temperature_>#{temperatureMax}
+
+                    select count(DISTINCT person_id) from base_person_device_filter_log
+                    where record_time >=#{startTime}
+                    and record_time <= #{endTime}
+                    and temperature_>#{temperatureMax}
+
         ]]>
     </select>
     <select id="getDayAbnormalNumByCompanyList" resultType="Integer">
@@ -323,7 +332,7 @@
         and a.record_time &lt;= #{endTime}
         and a.temperature_>#{temperatureMax}
         and b.company_id in
-        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">   #{item.id}
+        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">#{item.id}
         </foreach>
         and a.del_flag = 0
     </select>
@@ -334,7 +343,7 @@
         where a.record_time >=#{startTime}
         and a.record_time &lt;= #{endTime}
         and b.company_id in
-        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">   #{item.id}
+        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">#{item.id}
         </foreach>
         and a.del_flag = 0
         <if test="popedom!=null">
@@ -353,22 +362,26 @@
     </select>
     <select id="countDayByPersonIdAndDate" resultType="Integer">
         <![CDATA[
-            select count(distinct(DATE_FORMAT(a.record_time,'%y-%m-%d'))) from base_person_device_filter_log a
-            where a.person_id=#{personId}
-            and a.record_time>=#{startDate}
-            and a.record_time<#{endDate}
-            and a.del_flag=0
+
+                    select count(distinct(DATE_FORMAT(a.record_time,'%y-%m-%d'))) from base_person_device_filter_log a
+                    where a.person_id=#{personId}
+                    and a.record_time>=#{startDate}
+                    and a.record_time<#{endDate}
+                    and a.del_flag=0
+
         ]]>
     </select>
     <select id="countDetectedByCompanyId" resultType="int">
         <![CDATA[
-            select count(distinct(a.person_id)) from base_person_device_filter_log a
-            left join base_person_info b on a.person_id = b.id_
-            where b.company_id=#{companyId}
-            and a.record_time>=#{startDate}
-            and a.record_time<#{endDate}
-            and a.del_flag=0
-            and b.del_flag=0
+
+                    select count(distinct(a.person_id)) from base_person_device_filter_log a
+                    left join base_person_info b on a.person_id = b.id_
+                    where b.company_id=#{companyId}
+                    and a.record_time>=#{startDate}
+                    and a.record_time<#{endDate}
+                    and a.del_flag=0
+                    and b.del_flag=0
+
         ]]>
     </select>
     <select id="findUndetectedByCompanyCode"
@@ -387,13 +400,14 @@
         ]]>
         and (
         b.code_ like #{searchParams.companyCode}
-<!--        <if test="personId!=null">
-            or b.id_ in (
-            select d.company_id from base_person_company d where d.person_id = #{personId}
-            )
-        </if>-->
+        <!--        <if test="personId!=null">
+                    or b.id_ in (
+                    select d.company_id from base_person_company d where d.person_id = #{personId}
+                    )
+                </if>-->
         <if test="searchParams.personCompanyList!=null">
-            <foreach collection="searchParams.personCompanyList" index="index" item="item" open=" or b.id_ in(" separator="," close=")">
+            <foreach collection="searchParams.personCompanyList" index="index" item="item" open=" or b.id_ in("
+                     separator="," close=")">
                 #{item.companyId}
             </foreach>
         </if>
@@ -403,15 +417,54 @@
 
     <select id="getDayCheckedPersonByCompanyList" resultMap="PersonDeviceFilterLogMap">
         <![CDATA[
-         select * from base_person_device_filter_log a left join base_person_info b
-        on a.person_id = b.id_
-        where  a.record_time>=#{startDate}
-        and a.record_time<#{endDate}
-        and a.del_flag=0
-        and b.company_id = #{companyInfo.id}
+            select * from base_person_device_filter_log a left join base_person_info b
+            on a.person_id = b.id_
+            where  a.record_time>=#{startDate}
+            and a.record_time<#{endDate}
+            and a.del_flag=0
+            and b.company_id = #{companyInfo.id}
+        ]]>
+        group by a.person_id order by a.record_time desc
+    </select>
+    <select id="countDetectedByCompanyIds" resultType="long">
+        <![CDATA[
+            SELECT count(distinct(b.id_)) from base_person_device_filter_log a ,base_person_info b
+            where a.person_id = b.id_
+            and a.del_flag = 0
+            and b.del_flag = 0
+            and a.record_time>=#{startTime}
+            and a.record_time<=#{endTime}
+        ]]>
+        <foreach collection="companyIds" index="index" item="item" open="and b.company_id in(" separator=","
+                 close=")">
+            #{item}
+        </foreach>
+    </select>
 
+    <select id="findUndetectedPersonListByCompanyIds" resultMap="com.jpsoft.smart.modules.base.dao.PersonInfoDAO.PersonInfoMap">
+        <![CDATA[
+        SELECT * from base_person_info where id_ not in (
+            SELECT b.id_ from base_person_device_filter_log a ,base_person_info b
+            where a.person_id = b.id_
+            and a.del_flag = 0
+            and b.del_flag = 0
+            and a.record_time>=#{startTime}
+            and a.record_time<=#{endTime}
+        ]]>
+        <foreach collection="companyIds" index="index" item="item" open="and b.company_id in(" separator="," close=")">
+            #{item}
+        </foreach>
+        <![CDATA[
+         GROUP BY a.person_id )
+            and base_person_info.del_flag = 0
         ]]>
+        <foreach collection="companyIds" index="index" item="item" open="and base_person_info.company_id in(" separator="," close=")">
+            #{item}
+        </foreach>
+
+
+
+
 
-        group by a.person_id order by a.record_time desc
     </select>
 </mapper>

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

@@ -6,7 +6,9 @@
     <sql id="Base_Column_List">
 	device_no,
 	person_id,
+	person_name,
 	id_,
+	identity_no,
 	create_by,
 	create_time,
 	update_by,
@@ -35,7 +37,9 @@
         <result property="delFlag" column="del_flag" />
         <result property="deviceNo" column="device_no" />
         <result property="personId" column="person_id" />
+        <result property="personName" column="person_name"/>
         <result property="temperature" column="temperature_" />
+        <result property="identityNo" column="identity_no"/>
         <result property="matchStatus" column="match_status" />
         <result property="matchMsg" column="match_msg" />
         <result property="matchFaceId" column="match_face_id" />
@@ -56,7 +60,7 @@
         -->
         <![CDATA[
 		insert into base_person_device_log
-	    (id_,create_by,create_time,update_by,update_time,is_effective,del_flag,device_no,person_id,temperature_,match_status,match_msg,match_face_id,face_image,record_time)
+	    (id_,create_by,create_time,update_by,update_time,is_effective,del_flag,device_no,person_id,person_name,temperature_,identity_no,match_status,match_msg,match_face_id,face_image,record_time)
 		values
 		(
         #{id,jdbcType=VARCHAR}
@@ -68,7 +72,9 @@
         ,#{delFlag,jdbcType= NUMERIC }
         ,#{deviceNo,jdbcType=VARCHAR}
         ,#{personId,jdbcType=VARCHAR}
+        ,#{personName,jdbcType=VARCHAR}
         ,#{temperature,jdbcType=NUMERIC}
+        ,#{identityNo,jdbcType=VARCHAR}
         ,#{matchStatus,jdbcType=INTEGER}
         ,#{matchMsg,jdbcType=VARCHAR}
         ,#{matchFaceId,jdbcType= INTEGER}

+ 52 - 3
common/src/main/resources/mapper/base/PersonDeviceRelation.xml

@@ -107,18 +107,66 @@ id_,device_id,person_id,del_flag,create_by,create_time,update_by,update_time		fr
 	</select>
 	<select id="search" parameterType="hashmap" resultMap="PersonDeviceRelationMap">
 		<![CDATA[
-			select * from base_person_device_relation a
+			select a.* from base_person_device_relation a
 			LEFT JOIN base_device_info b ON a.device_id = b.id_
+			LEFT JOIN base_person_info c ON a.person_id = c.id_
+			LEFT JOIN base_company_info d ON c.company_id = d.id_
 		]]>
 		<where>
 			and a.del_flag = false
 			and b.del_flag = false
+			and c.del_flag = false
+			and d.del_flag = false
 			<if test="searchParams.deviceId != null">
-			and a.device_id = #{searchParams.deviceId}
-		</if>
+				and a.device_id = #{searchParams.deviceId}
+			</if>
 			<if test="searchParams.personId != null">
 				and a.person_id = #{searchParams.personId}
 			</if>
+			<if test="searchParams.companyId != null">
+				and c.company_id = #{searchParams.companyId}
+			</if>
+			<if test="searchParams.companyCode != null">
+				and d.code_ like #{searchParams.companyCode}
+			</if>
+			<if test="searchParams.name != null">
+				and c.name_ like #{searchParams.name}
+			</if>
+			<if test="searchParams.nameList != null">
+				<foreach item="name" collection="searchParams.nameList" open="and (" separator="or" close=")">
+					c.name_ like #{name}
+				</foreach>
+			</if>
+			<if test="searchParams.idCard != null">
+				and c.id_card like #{searchParams.idCard}
+			</if>
+			<if test="searchParams.phone != null">
+				and c.phone_ like #{searchParams.phone}
+			</if>
+			<if test="searchParams.position1 != null">
+				and c.position1_ like #{searchParams.position1}
+			</if>
+			<if test="searchParams.position2 != null">
+				and c.position2_ like #{searchParams.position2}
+			</if>
+			<if test="searchParams.position3 != null">
+				and c.position3_ like #{searchParams.position3}
+			</if>
+			<if test="searchParams.position4 != null">
+				and c.position4_ like #{searchParams.position4}
+			</if>
+			<if test="searchParams.position5 != null">
+				and c.position5_ like #{searchParams.position5}
+			</if>
+			<if test="searchParams.faceBound != null">
+				and c.face_bound = #{searchParams.faceBound}
+			</if>
+			<if test="'1'.toString() == searchParams.isUploadPhoto and null != searchParams.isUploadPhoto">
+				and c.face_image_url is not null
+			</if>
+			<if test="'0'.toString() == searchParams.isUploadPhoto and null != searchParams.isUploadPhoto">
+				and c.face_image_url is null
+			</if>
 		</where>
 		<foreach item="sort" collection="sortList"  open="order by" separator=",">
 	        a.${sort.name} ${sort.order}
@@ -129,6 +177,7 @@ id_,device_id,person_id,del_flag,create_by,create_time,update_by,update_time		fr
 		where a.person_id=#{personId}
 		and a.device_id = b.id_
 		and a.del_flag=false
+		and b.del_flag=false
 	</select>
 
     <select id="findByIsBoundAndUpdateTime" resultMap="PersonDeviceRelationMap">

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

@@ -350,4 +350,23 @@
     <select id="countByCompanyId" resultType="long">
         select count(*) from base_person_info where company_id=#{0} and del_flag=0
     </select>
+
+    <select id="countByCompanyIds" resultType="long">
+        <![CDATA[
+        select count(*) from base_person_info where  del_flag=0
+        ]]>
+        <foreach collection="list" index="index" item="item" open="and company_id in(" separator="," close=")">
+            #{item}
+        </foreach>
+    </select>
+
+    <select id="findByIdCardAndCompanyId" resultMap="PersonInfoMap">
+        <![CDATA[
+         select * from base_person_info where del_flag = 0
+            and id_card = #{idCard}
+            and company_id = #{companyId}
+                ]]>
+
+
+</select>
 </mapper>

+ 13 - 6
lapi/src/main/java/com/jpsoft/smart/lapi/handler/PersonVerificationHandler.java

@@ -2,6 +2,7 @@ package com.jpsoft.smart.lapi.handler;
 
 import cn.hutool.json.JSONObject;
 import com.jpsoft.smart.lapi.dto.PersonVerification;
+import com.jpsoft.smart.modules.base.entity.PersonInfo;
 import com.jpsoft.smart.modules.base.service.PersonDeviceFilterLogService;
 import com.jpsoft.smart.modules.base.service.PersonDeviceLogService;
 import com.jpsoft.smart.modules.business.service.WorkAttendanceService;
@@ -49,6 +50,8 @@ public class PersonVerificationHandler extends SimpleChannelInboundHandler<Perso
 
         JSONObject jsonObject = personVerification.getJsonObject();
 
+       // log.warn(jsonObject.toString());
+
         JSONObject faceJson = new JSONObject(jsonObject.getStr("FaceInfoList").substring(1,jsonObject.getStr("FaceInfoList").length()-1));
 
         Long timestamp = faceJson.getLong("Timestamp");
@@ -57,7 +60,7 @@ public class PersonVerificationHandler extends SimpleChannelInboundHandler<Perso
              timestamp =new Double(timestampDouble).longValue() ;
         }
 
-        log.warn(String.valueOf(timestamp));
+    //    log.warn(String.valueOf(timestamp));
         Date date = new Date(timestamp);
 
         //设备序列号
@@ -66,6 +69,9 @@ public class PersonVerificationHandler extends SimpleChannelInboundHandler<Perso
         //人员温度信息
         BigDecimal temperature = faceJson.getBigDecimal("Temperature");
 
+        //戴口罩状态(0:未开启口罩验证,1:未戴口罩,2:戴口罩)
+        Integer maskFlag = faceJson.getInt("MaskFlag");
+
         //人员抓拍信息
         JSONObject faceImageJson = faceJson.getJSONObject("FaceImage");
 
@@ -103,19 +109,20 @@ public class PersonVerificationHandler extends SimpleChannelInboundHandler<Perso
         }).start();
 
         //记录人员记录
-        personDeviceLogService.deviceInsertLog(deviceNo,temperature,faceImageJson,libMatInfoListJson,matchPersonInfo,date);
+        personDeviceLogService.deviceInsertLog(deviceNo,temperature,faceImageJson,libMatInfoListJson,matchPersonInfo,date,maskFlag);
 
         //记录人员过滤记录
-        personDeviceFilterLogService.deviceInsertFilterLog(deviceNo,temperature,faceImageJson,libMatInfoListJson,matchPersonInfo,date);
+        personDeviceFilterLogService.deviceInsertFilterLog(deviceNo,temperature,faceImageJson,libMatInfoListJson,matchPersonInfo,date,maskFlag);
 
         //记录考勤信息
         try {
-            final Integer personId = LApiUtil.getPersonCode(libMatInfoListJson, matchPersonInfo);
+          //  final Integer personId = LApiUtil.getPersonCode(libMatInfoListJson, matchPersonInfo);
+            final PersonInfo personInfo = LApiUtil.getPersonCode(libMatInfoListJson, matchPersonInfo);
             final BigDecimal fTemperature = temperature;
             final Date recordDate = date;
 
-            if(personId!=null && personId!=0) {
-                new Thread(() -> workAttendanceService.punchIn(personId.longValue(), fTemperature, recordDate)).start();
+            if(personInfo.getId()!=null && personInfo.getId()!=0L) {
+                new Thread(() -> workAttendanceService.punchIn(personInfo.getId(), fTemperature, recordDate)).start();
             }
         }
         catch (Exception ex){

+ 2 - 2
web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonDeviceLogController.java

@@ -68,7 +68,7 @@ public class PersonDeviceLogController {
     @RequestMapping(value = "pageList", method = RequestMethod.POST)
     @ApiImplicitParams({
             @ApiImplicitParam(name = "companyId", value = "所属单位编号", paramType = "query"),
-            @ApiImplicitParam(name = "subordinate", value = "会否保护下级单位", required = false, paramType = "query", dataType = "String"),
+            @ApiImplicitParam(name = "subordinate", value = "是否查询下级单位", required = false, paramType = "query", dataType = "String"),
             @ApiImplicitParam(name = "deviceNo", value = "设备编号", paramType = "query"),
             @ApiImplicitParam(name = "aliasName", value = "设备别名", paramType = "query"),
             @ApiImplicitParam(name = "personName", value = "人员姓名", paramType = "query"),
@@ -197,7 +197,7 @@ public class PersonDeviceLogController {
     @PostMapping("exportXls")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "companyId", value = "所属单位编号", paramType = "query"),
-            @ApiImplicitParam(name = "subordinate", value = "会否保护下级单位", required = false, paramType = "query", dataType = "String"),
+            @ApiImplicitParam(name = "subordinate", value = "是否查询下级单位", required = false, paramType = "query", dataType = "String"),
             @ApiImplicitParam(name = "deviceNo", value = "设备编号", paramType = "query"),
             @ApiImplicitParam(name = "aliasName", value = "设备别名", paramType = "query"),
             @ApiImplicitParam(name = "personName", value = "人员姓名", paramType = "query"),

+ 288 - 0
web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonDeviceRelationController.java

@@ -4,8 +4,11 @@ import com.alipay.api.domain.Person;
 import com.github.pagehelper.Page;
 import com.github.pagehelper.util.StringUtil;
 import com.jpsoft.smart.config.OSSConfig;
+import com.jpsoft.smart.modules.base.dto.PersonInfoDTO;
+import com.jpsoft.smart.modules.base.entity.CompanyInfo;
 import com.jpsoft.smart.modules.base.entity.DeviceInfo;
 import com.jpsoft.smart.modules.base.entity.PersonInfo;
+import com.jpsoft.smart.modules.base.service.CompanyInfoService;
 import com.jpsoft.smart.modules.base.service.DeviceInfoService;
 import com.jpsoft.smart.modules.base.service.PersonInfoService;
 import com.jpsoft.smart.modules.common.utils.OSSUtil;
@@ -41,6 +44,7 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.stream.Collectors;
 
 @RestController
 @RequestMapping("/personDeviceRelation")
@@ -69,6 +73,10 @@ public class PersonDeviceRelationController {
     @Autowired
     private PersonInfoService personInfoService;
 
+    @Autowired
+    private CompanyInfoService companyInfoService;
+
+
 
     
     @ApiOperation(value="添加设备和人员绑定")
@@ -786,7 +794,287 @@ public class PersonDeviceRelationController {
 
     }
 
+    @ApiOperation(value="设备人员列表")
+    @RequestMapping(value = "devicePersonList",method = RequestMethod.POST)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "name",value = "姓名", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "idCard",value = "身份证", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "phone",value = "手机号", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "parentId",value = "上级企业ID", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "subordinate",value = "是否查询下级单位", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "derviceId",value = "设备编号", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "position1",value = "一级位置", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "position2",value = "二级位置", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "position3",value = "三级位置", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "position4",value = "四级位置", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "position5",value = "五级位置", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "faceBound",value = "是否同步", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "isUploadPhoto",value = "是否上传照片", required = false, paramType = "form",dataType = "String")
+    })
+    public MessageResult<Map> devicePersonList(
+            @RequestParam(value="name",defaultValue="") String name,
+            @RequestParam(value="idCard",defaultValue="") String idCard,
+            @RequestParam(value="phone",defaultValue="") String phone,
+            @RequestParam(value="companyCode",defaultValue="")  String companyCode,
+            @RequestParam(value="parentId",defaultValue="")  String parentId,
+            @RequestParam(value="subordinate",defaultValue="false")  Boolean subordinate,
+            @RequestParam(value="deviceId",defaultValue="") String deviceId,
+            @RequestParam(value="position1",defaultValue="") String position1,
+            @RequestParam(value="position2",defaultValue="") String position2,
+            @RequestParam(value="position3",defaultValue="") String position3,
+            @RequestParam(value="position4",defaultValue="") String position4,
+            @RequestParam(value="position5",defaultValue="") String position5,
+            @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
+            @RequestParam(value="pageSize",defaultValue="20") int pageSize,
+            @RequestParam(value="faceBound",defaultValue="") Integer faceBound,
+            @RequestParam(value="isUploadPhoto",defaultValue="") String isUploadPhoto,
+            @RequestAttribute String subject){
+
+        //当前用户ID
+        User user = userService.get(subject);
+
+        CompanyInfo companyInfo = companyInfoService.get(user.getCompanyId());
+
+        MessageResult<Map> msgResult = new MessageResult<>();
+
+        Map<String,Object> searchParams = new HashMap<>();
+
+
+
+        if (StringUtils.isNotEmpty(name)) {
+            String[] names = name.split(",");
+            List nameList = new ArrayList();
+            for (String n : names) {
+                nameList.add("%"+ n +"%");
+            }
+            searchParams.put("nameList", nameList);
+        }
+
+        if (StringUtils.isNotEmpty(idCard)) {
+            searchParams.put("idCard","%" + idCard + "%");
+        }
+
+        if (StringUtils.isNotEmpty(phone)) {
+            searchParams.put("phone","%" + phone + "%");
+        }
+
+        if (StringUtils.isEmpty(companyCode)){
+            if (!userService.hasRole(subject,"SYSADMIN")) {
+                searchParams.put("companyCode", companyInfo.getCode() + "%");
+            }
+        }
+        else{
+            if(subordinate){
+                searchParams.put("companyCode", companyCode + "%");
+            }
+            else {
+                searchParams.put("companyCode", companyCode);
+            }
+        }
+
+        if(StringUtils.isNotEmpty(parentId)){
+            CompanyInfo parentCompanyInfo = companyInfoService.get(parentId);
+
+            String parentCode = parentCompanyInfo.getCode();
+
+            if (StringUtils.isEmpty(parentCode)){
+                if (!userService.hasRole(subject,"SYSADMIN")) {
+                    searchParams.put("companyCode", parentCode + "%");
+                }
+            }
+            else{
+                if(subordinate){
+                    searchParams.put("companyCode", parentCode + "%");
+                }
+                else {
+                    searchParams.put("companyCode", parentCode);
+                }
+            }
+        }
+
+        if (StringUtils.isNotEmpty(position1)) {
+            searchParams.put("position1","%" + position1 + "%");
+        }
+        if (StringUtils.isNotEmpty(position2)) {
+            searchParams.put("position2","%" + position2 + "%");
+        }
+        if (StringUtils.isNotEmpty(position3)) {
+            searchParams.put("position3","%" + position3 + "%");
+        }
+        if (StringUtils.isNotEmpty(position4)) {
+            searchParams.put("position4","%" + position4 + "%");
+        }
+        if (StringUtils.isNotEmpty(position5)) {
+            searchParams.put("position5","%" + position5 + "%");
+        }
 
+        if(faceBound != null){
+            searchParams.put("faceBound",faceBound);
+        }
+
+        if(StringUtils.isNotEmpty(isUploadPhoto)){
+            searchParams.put("isUploadPhoto", isUploadPhoto);
+        }
+
+        if(StringUtils.isNotEmpty(deviceId)){
+            searchParams.put("deviceId", deviceId);
+        }
+
+        List<Sort> sortList = new ArrayList<>();
+        sortList.add(new Sort("person_id","asc"));
+
+        Page<PersonDeviceRelation> page = personDeviceRelationService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
+
+//        Page<PersonInfo> page = personInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
+//        Page<PersonInfoDTO> pageDTO = PojoUtils.convertPage(page, PersonInfoDTO.class);
+//
+//        for(PersonInfoDTO dto : pageDTO.getResult()){
+//            List<DeviceInfo> deviceNameList = personDeviceRelationService.findDeviceByPersonId(dto.getId());
+//
+//            String deviceName = deviceNameList.stream()
+//                    .map((device)->device.getAliasName())
+//                    .collect(Collectors.joining(","));
+//
+//            dto.setDeviceName(deviceName);
+//        }
+
+        msgResult.setResult(true);
+        msgResult.setData(PojoUtils.pageWrapper(page));
 
+        return msgResult;
+    }
+
+    @ApiOperation(value="用户和单设备数据同步")
+    @PostMapping("devicePersonSync")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "personId", value = "人员ID", required = false, paramType = "form", dataType = "String"),
+            @ApiImplicitParam(name = "deviceId", value = "设备ID", required = false, paramType = "form", dataType = "String"),
+    })
+    public MessageResult<Boolean> devicePersonSync(
+            @RequestParam(value="personId",defaultValue="") String personId,
+            @RequestParam(value="deviceId",defaultValue="") String deviceId
+    ){
+        MessageResult<Boolean> msgResult = new MessageResult<>();
+        msgResult.setData(true);
+        msgResult.setResult(true);
+        try {
+            PersonInfo personInfo = personInfoService.get(Long.valueOf(personId));
+            if (personInfo==null){
+                throw new Exception("人员信息不存在!");
+            }
+
+            List<LapiResult> msgResultList = lapiService.addPersonForDeviceIds(personInfo.getId(),deviceId);
+            for (int i = 0; i < msgResultList.size(); i++) {
+                LapiResult lapiResult = msgResultList.get(i);
+                if (!lapiResult.isSuccess()) {
+                    throw  new Exception(lapiResult.getMsg());
+                }
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="用户和单设备数据同步")
+    @PostMapping("devicePersonsSync")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "personIds", value = "人员ID", required = false, paramType = "form", dataType = "String"),
+            @ApiImplicitParam(name = "deviceId", value = "设备ID", required = false, paramType = "form", dataType = "String"),
+    })
+    public MessageResult<Boolean> devicePersonsSync(
+            @RequestParam(value="personIds",defaultValue="") List<String> personIds,
+            @RequestParam(value="deviceId",defaultValue="") String deviceId
+            ){
+        MessageResult<Boolean> msgResult = new MessageResult<>();
+        msgResult.setData(true);
+        msgResult.setResult(true);
+
+        try {
+            HSSFWorkbook workbook = new HSSFWorkbook();
+            HSSFSheet sheet = workbook.createSheet();
+
+            for(String personId : personIds){
+                PersonInfo personInfo = personInfoService.get(Long.valueOf(personId));
+
+                if (personInfo==null){
+                    throw new Exception("人员信息不存在!");
+                }
+
+                if(!addPersonForDeviceIds(personInfo,deviceId, sheet)){
+                    msgResult.setData(false);
+                }
+            }
+
+            if(!msgResult.getData()){
+                ByteArrayOutputStream output = new ByteArrayOutputStream();
+                workbook.write(output);
+                byte[] buffer = output.toByteArray();
+                ByteArrayInputStream input = new ByteArrayInputStream(buffer);
+                String downloadUrl = OSSUtil.upload(ossConfig,"import","error.xls",input);
+
+                msgResult.setMessage(downloadUrl);
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
+    @ApiOperation(value="添加设备人员图片")
+    private Boolean addPersonForDeviceIds(PersonInfo personInfo,String deviceId, HSSFSheet sheet){
+        boolean bl = true;
+
+        try {
+            List<LapiResult> msgResultList = lapiService.addPersonForDeviceIds(personInfo.getId(),deviceId);
+
+            for (int i = 0; i < msgResultList.size(); i++) {
+                LapiResult lapiResult = msgResultList.get(i);
+                if (!lapiResult.isSuccess()) {
+                    Map resultMap = (Map)lapiResult.getData();
+                    HSSFRow row = sheet.createRow(sheet.getLastRowNum() + 1);
+                    HSSFCell cell1 = row.createCell(0);
+                    cell1.setCellValue(personInfo.getName());
+                    HSSFCell cell2 = row.createCell(1);
+                    cell2.setCellValue(resultMap.get("deviceAliasName").toString());
+                    HSSFCell cell3 = row.createCell(2);
+                    cell3.setCellValue("绑定人脸信息失败!");
+                    HSSFCell cell4 = row.createCell(3);
+                    cell4.setCellValue(lapiResult.getMsg());
+
+                    bl = false;
+                }
+            }
+        }catch(Exception ex) {
+            logger.error(ex.getMessage(), ex);
+            bl = false;
+
+            HSSFRow row = sheet.createRow(sheet.getLastRowNum() + 1);
+
+            HSSFCell cell1 = row.createCell(0);
+            cell1.setCellValue(personInfo.getName());
+
+            HSSFCell cell2 = row.createCell(1);
+            cell2.setCellValue("");
+
+            HSSFCell cell3 = row.createCell(2);
+            cell3.setCellValue("");
+
+            HSSFCell cell4 = row.createCell(3);
+            cell4.setCellValue(ex.getMessage());
+        }
+
+        return bl;
+    }
 
 }

+ 43 - 12
web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonInfoController.java

@@ -229,6 +229,9 @@ public class PersonInfoController {
             PersonCompany classPersonCompany = null;
             for(String pc : pcs){
                 //添加
+                if(StringUtils.isEmpty(pc)){
+                    continue;
+                }
                 classPersonCompany = new PersonCompany();
                 classPersonCompany.setId(UUID.randomUUID().toString());
                 classPersonCompany.setCompanyId(pc);
@@ -431,7 +434,8 @@ public class PersonInfoController {
             @ApiImplicitParam(name = "idCard",value = "身份证", required = false, paramType = "form",dataType = "String"),
             @ApiImplicitParam(name = "phone",value = "手机号", required = false, paramType = "form",dataType = "String"),
             @ApiImplicitParam(name = "companyCode",value = "企业编码", required = false, paramType = "form",dataType = "String"),
-            @ApiImplicitParam(name = "subordinate",value = "会否保护下级单位", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "parentId",value = "上级企业ID", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "subordinate",value = "是否查询下级单位", required = false, paramType = "form",dataType = "String"),
             @ApiImplicitParam(name = "derviceName",value = "设备名称", required = false, paramType = "form",dataType = "String"),
             @ApiImplicitParam(name = "position1",value = "一级位置", required = false, paramType = "form",dataType = "String"),
             @ApiImplicitParam(name = "position2",value = "二级位置", required = false, paramType = "form",dataType = "String"),
@@ -446,6 +450,7 @@ public class PersonInfoController {
             @RequestParam(value="idCard",defaultValue="") String idCard,
             @RequestParam(value="phone",defaultValue="") String phone,
             @RequestParam(value="companyCode",defaultValue="")  String companyCode,
+            @RequestParam(value="parentId",defaultValue="")  String parentId,
             @RequestParam(value="subordinate",defaultValue="false")  Boolean subordinate,
             @RequestParam(value="derviceName",defaultValue="") String derviceName,
             @RequestParam(value="position1",defaultValue="") String position1,
@@ -502,6 +507,26 @@ public class PersonInfoController {
             }
         }
 
+        if(StringUtils.isNotEmpty(parentId)){
+            CompanyInfo parentCompanyInfo = companyInfoService.get(parentId);
+
+            String parentCode = parentCompanyInfo.getCode();
+
+            if (StringUtils.isEmpty(parentCode)){
+                if (!userService.hasRole(subject,"SYSADMIN")) {
+                    searchParams.put("companyCode", parentCode + "%");
+                }
+            }
+            else{
+                if(subordinate){
+                    searchParams.put("companyCode", parentCode + "%");
+                }
+                else {
+                    searchParams.put("companyCode", parentCode);
+                }
+            }
+        }
+
         if (StringUtils.isNotEmpty(position1)) {
             searchParams.put("position1","%" + position1 + "%");
         }
@@ -951,8 +976,8 @@ public class PersonInfoController {
             @ApiImplicitParam(name = "name",value = "姓名", required = false, paramType = "form",dataType = "String"),
             @ApiImplicitParam(name = "idCard",value = "身份证", required = false, paramType = "form",dataType = "String"),
             @ApiImplicitParam(name = "phone",value = "手机号", required = false, paramType = "form",dataType = "String"),
-            @ApiImplicitParam(name = "companyCode",value = "企业编码", required = false, paramType = "form",dataType = "String"),
-            @ApiImplicitParam(name = "subordinate",value = "会否保护下级单位", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "parentId",value = "企业编号", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "subordinate",value = "是否查询下级单位", required = false, paramType = "form",dataType = "String"),
             @ApiImplicitParam(name = "position1",value = "一级位置", required = false, paramType = "form",dataType = "String"),
             @ApiImplicitParam(name = "position2",value = "二级位置", required = false, paramType = "form",dataType = "String"),
             @ApiImplicitParam(name = "position3",value = "三级位置", required = false, paramType = "form",dataType = "String"),
@@ -965,7 +990,7 @@ public class PersonInfoController {
             @RequestParam(value="name",defaultValue="") String name,
             @RequestParam(value="idCard",defaultValue="") String idCard,
             @RequestParam(value="phone",defaultValue="") String phone,
-            @RequestParam(value="companyCode",defaultValue="")  String companyCode,
+            @RequestParam(value="parentId",defaultValue="")  String parentId,
             @RequestParam(value="subordinate",defaultValue="false")  Boolean subordinate,
             @RequestParam(value="position1",defaultValue="") String position1,
             @RequestParam(value="position2",defaultValue="") String position2,
@@ -1054,17 +1079,21 @@ public class PersonInfoController {
                 searchParams.put("phone","%" + phone + "%");
             }
 
-            if (StringUtils.isEmpty(companyCode)){
-                if (!userService.hasRole(subject,"SYSADMIN")) {
-                    searchParams.put("companyCode", companyInfo.getCode() + "%");
+            if (StringUtils.isNotEmpty(parentId)) {
+                CompanyInfo parent = companyInfoService.get(parentId);
+                String companyCode = parent!=null ? parent.getCode() : "";
+
+                if (StringUtils.isNotEmpty(companyCode)) {
+                    if (subordinate) {
+                        searchParams.put("companyCode", companyCode + "%");
+                    } else {
+                        searchParams.put("companyCode", companyCode);
+                    }
                 }
             }
             else{
-                if(subordinate){
-                    searchParams.put("companyCode", companyCode + "%");
-                }
-                else {
-                    searchParams.put("companyCode", companyCode);
+                if (!userService.hasRole(subject, "SYSADMIN")) {
+                    searchParams.put("companyCode", companyInfo.getCode() + "%");
                 }
             }
 //            if (userService.hasRole(subject,"SYSADMIN")) {
@@ -1284,4 +1313,6 @@ public class PersonInfoController {
 
         return bl;
     }
+
+
 }

+ 23 - 5
web/src/main/java/com/jpsoft/smart/modules/base/controller/ReportController.java

@@ -48,9 +48,15 @@ public class ReportController {
     @ApiOperation(value = "获取每个单位的人数和打卡人数")
     @PostMapping("getCompanyRecordReport")
     @ApiImplicitParams({
+            @ApiImplicitParam(name = "parentId",value = "上级单位ID", required = false, paramType = "form",dataType = "String"),
+            @ApiImplicitParam(name = "subordinate",value = "是否查询下级单位", required = false, paramType = "form",dataType = "String"),
             @ApiImplicitParam(name = "timeRanges",value = "时间范围", paramType = "query")
     })
-    public MessageResult<Map> getCompanyRecordReport(@RequestParam(value="timeRanges",defaultValue = "") String timeRanges,@RequestAttribute String subject) {
+    public MessageResult<Map> getCompanyRecordReport(
+            @RequestParam(value="parentId",defaultValue="")  String parentId,
+            @RequestParam(value="subordinate",defaultValue="false")  Boolean subordinate,
+            @RequestParam(value="timeRanges",defaultValue = "") String timeRanges,
+            @RequestAttribute String subject) {
 
         MessageResult<Map> msgResult = new MessageResult<>();
         HashMap<String, Object> map = new HashMap<>();
@@ -59,11 +65,23 @@ public class ReportController {
             List<CompanyInfo> list = new ArrayList<>();
 
             //系统管理者和非系统管理者公司列表
-            if (userService.hasRole(subject, "SYSADMIN")) {
-                list = companyInfoService.list();
+            if(StringUtil.isNotEmpty(parentId)){
+                CompanyInfo companyInfo = companyInfoService.get(parentId);
+                String code = "";
+                if (subordinate) {
+                    code = companyInfo.getCode() + "%";
+                } else {
+                    code = companyInfo.getCode();
+                }
+                list = companyInfoService.findByCompanyCode(code, null);
+
             }else {
-                CompanyInfo companyInfo = companyInfoService.get(user.getCompanyId());
-                list = companyInfoService.findByCompanyCode(companyInfo.getCode() + "%", null);
+                if (userService.hasRole(subject, "SYSADMIN")) {
+                    list = companyInfoService.list();
+                } else {
+                    CompanyInfo companyInfo = companyInfoService.get(user.getCompanyId());
+                    list = companyInfoService.findByCompanyCode(companyInfo.getCode() + "%", null);
+                }
             }
 
             //查询时间

+ 38 - 5
web/src/main/java/com/jpsoft/smart/modules/mobile/controller/PersonDeviceLogApiController.java

@@ -240,7 +240,7 @@ public class PersonDeviceLogApiController {
 
             if (StringUtils.isNotEmpty(filter) && "1".equals(filter)){
                 personSearchParam.put("abnormalDate",queryDate);
-                personSearchParam.put("temperature",temperatureConfig.getMax());
+                personSearchParam.put("temperatureMax",temperatureConfig.getMax());
             }
 
             List<Sort> sortList1 = new ArrayList<>();
@@ -645,8 +645,28 @@ public class PersonDeviceLogApiController {
             }
 
             List<PersonCompany> personCompanyList = personCompanyService.findByPersonId(personInfo.getId());
+            List<String> companyIds = personCompanyList.stream().map(PersonCompany::getCompanyId).collect(Collectors.toList());
+            List<CompanyInfo> companyInfoList = companyInfoService.findByCompanyCode(companyInfo.getCode(),null);
+            if (companyInfoList.size()>0){
+                for (CompanyInfo companyInfo1:companyInfoList){
+                    if (!companyIds.contains(companyInfo1.getId())){
+                        companyIds.add(companyInfo1.getId());
+                    }
+                }
+            }
+
+
+
+
+            long detectedCount = personDeviceFilterLogService.countDetectedByCompanyIds(companyIds,startTime,endTime);
+            long peronNumCompany = personInfoService.countByCompanyIds(companyIds);
+
+            long undetectedCount = peronNumCompany - detectedCount;
 
-            long undetectedCount = personDeviceFilterLogService.countUndetectedByCompanyCode(companyInfo.getCode() + "%",personCompanyList,startTime,endTime);
+
+
+
+       //     long undetectedCount = personDeviceFilterLogService.countUndetectedByCompanyCode(companyInfo.getCode() + "%",personCompanyList,startTime,endTime);
 
             map.put("companyTotalCount",companyTotalCount);
             map.put("personTotalCount",personTotalCount);
@@ -701,17 +721,30 @@ public class PersonDeviceLogApiController {
             }
 
             Map<String,Object> searchParams = new HashMap<>();
-            searchParams.put("companyCode",companyInfo.getCode() + "%");
+    //        searchParams.put("companyCode",companyInfo.getCode() + "%");
 //            searchParams.put("personId",personInfo.getId());
 
             List<PersonCompany> personCompanyList = personCompanyService.findByPersonId(personInfo.getId());
 
-            searchParams.put("personCompanyList",personCompanyList);
+            List<String> companyIds = personCompanyList.stream().map(PersonCompany::getCompanyId).collect(Collectors.toList());
+            List<CompanyInfo> companyInfoList = companyInfoService.findByCompanyCode(companyInfo.getCode(),null);
+            if (companyInfoList.size()>0){
+                for (CompanyInfo companyInfo1:companyInfoList){
+                    if (!companyIds.contains(companyInfo1.getId())){
+                        companyIds.add(companyInfo1.getId());
+                    }
+                }
+            }
+
+
 
+        //    searchParams.put("personCompanyList",personCompanyList);
             searchParams.put("startTime",startTime);
             searchParams.put("endTime",endTime);
+            searchParams.put("companyIds",companyIds);
 
-            Page<PersonInfo> page = personDeviceFilterLogService.findUndetectedPersonList(searchParams,pageIndex,pageSize,true);
+       //     Page<PersonInfo> page = personDeviceFilterLogService.findUndetectedPersonList(searchParams,pageIndex,pageSize,true);
+            Page<PersonInfo> page = personDeviceFilterLogService.findUndetectedPersonListByCompanyIds(searchParams,pageIndex,pageSize,true);
 
             msgResult.setResult(true);
             msgResult.setData(PojoUtils.pageWrapper(page));