Преглед на файлове

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

jz.kai преди 5 години
родител
ревизия
f7985dbe0c

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

@@ -39,4 +39,6 @@ public interface PersonInfoDAO {
     long countByCompanyIds(List<String> companyIds);
 
     PersonInfo findByIdCardAndCompanyId(String idCard,String companyId);
+
+	List<PersonInfo> notGuestList();
 }

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

@@ -38,4 +38,6 @@ public interface PersonInfoService {
     long countByCompanyIds(List<String> companyIds);
 
     PersonInfo addPersonForCompany(PersonInfo personInfo, String deviceNo);
+
+	List<PersonInfo> notGuestList();
 }

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

@@ -20,6 +20,7 @@ import com.jpsoft.smart.modules.common.utils.TimeZonesUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
 import sun.misc.BASE64Decoder;
@@ -61,6 +62,7 @@ public class PersonDeviceFilterLogServiceImpl implements PersonDeviceFilterLogSe
     }
 
     @Override
+    @Async
     public void deviceInsertFilterLog(String deviceNo, BigDecimal temperature, JSONObject faceImageJson, JSONObject libMatInfoListJson, JSONObject matchPersonInfo, Date date,Integer maskFlag) {
 
         try {

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

@@ -70,6 +70,7 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
 
 
     @Override
+    @Async
     public void deviceInsertLog(String deviceNo, BigDecimal temperature, JSONObject faceImageJson, JSONObject libMatInfoListJson, JSONObject matchPersonInfo, Date date,Integer maskFlag) {
         String retFileUrl = "";
         try {

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

@@ -156,6 +156,7 @@ public class PersonInfoServiceImpl implements PersonInfoService {
 					personInfo2.setPopedom("1");
 					personInfo2.setWechatNoticeEnabled(false);
 					personInfo2.setAllowViewLocal(false);
+					personInfo2.setGuestEnabled(true);
 					personInfoDAO.insert(personInfo2);
 					return personInfo2;
 				}else {
@@ -173,4 +174,9 @@ public class PersonInfoServiceImpl implements PersonInfoService {
 			return personInfo;
 		}
 	}
+
+	@Override
+	public List<PersonInfo> notGuestList() {
+		return personInfoDAO.notGuestList();
+	}
 }

+ 5 - 3
common/src/main/resources/mapper/base/PersonDeviceFilterLog.xml

@@ -326,13 +326,14 @@
         ]]>
     </select>
     <select id="getDayAbnormalNumByCompanyList" resultType="Integer">
+        <![CDATA[
         select count(DISTINCT person_id) from base_person_device_filter_log a left join base_person_info b
         on a.person_id = b.id_
         where a.record_time >=#{startTime}
-        and a.record_time &lt;= #{endTime}
+        and a.record_time <= #{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="and b.company_id in(" separator="," close=")">#{item.id}
         </foreach>
         and a.del_flag = 0
     </select>
@@ -342,6 +343,7 @@
         on a.person_id = b.id_
         where a.record_time >=#{startTime}
         and a.record_time &lt;= #{endTime}
+        and b.guest_enabled is not true
         and b.company_id in
         <foreach collection="list" index="index" item="item" open="(" separator="," close=")">#{item.id}
         </foreach>

+ 8 - 4
common/src/main/resources/mapper/base/PersonDeviceLog.xml

@@ -238,7 +238,7 @@
     </select>
     <select id="getDayCheckedVistorNumByDeviceNoList" resultType="Integer">
         <![CDATA[
-            select count(*) from base_person_device_log where person_id = 0
+            select count(*) from base_person_device_log where match_face_id = 0
             and record_time >=#{startTime}
             and record_time <= #{endTime}
             and temperature_ > 0
@@ -284,6 +284,7 @@
             from base_person_device_log m inner join base_person_info n ON m.person_id = n.id_
             where m.record_time>=#{startTime}
             and m.record_time <=#{endTime}
+            and n.guest_enabled is not true
         ]]>
         <foreach collection="companyList" index="index" item="item" open=" and n.company_id in (" separator="," close=")">
             #{item.id}
@@ -297,7 +298,7 @@
     <select id="findVisitorLogByDeviceNoList" resultMap="PersonDeviceLogMap">
         <![CDATA[
             select * from base_person_device_log
-            where person_id = 0
+            where match_face_id = 0
             and record_time >= #{startTime}
             and record_time <= #{endTime}
             and temperature_>0
@@ -315,7 +316,8 @@
             from base_person_device_log m inner join base_person_info n ON m.person_id = n.id_
             where m.record_time>=#{startTime}
             and m.record_time <=#{endTime}
-            and popedom_ like '%2%'
+            and n.popedom_ like '%2%'
+            and n.guest_enabled is not true
         ]]>
         <foreach collection="list" index="index" item="item" open=" and n.company_id in (" separator="," close=")">
             #{item.id}
@@ -353,7 +355,8 @@
             from base_person_device_log m inner join base_person_info n ON m.person_id = n.id_
             where m.record_time>=#{startTime}
             and m.record_time <=#{endTime}
-            and popedom_ = '1'
+            and n.popedom_ = '1'
+            and n.guest_enabled is not true
         ]]>
         <foreach collection="list" index="index" item="item" open=" and n.company_id in (" separator="," close=")">
             #{item.id}
@@ -386,6 +389,7 @@
         on a.person_id = b.id_
         where a.record_time >=#{startTime}
         and a.record_time &lt;= #{endTime}
+        and b.guest_enabled is not true
         <foreach collection="list" index="index" item="item" open=" and b.company_id in (" separator="," close=")">   #{item.id}
         </foreach>
         and a.del_flag = 0

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

@@ -317,9 +317,11 @@
     </select>
 
     <select id="countByCompanyList" resultType="Long">
-        select count(*) from base_person_info where del_flag = 0 and
-        company_id in
-        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
+        <![CDATA[
+        select count(*) from base_person_info where del_flag = 0
+        and guest_enabled is not true
+        ]]>
+        <foreach collection="list" index="index" item="item" open="and company_id in(" separator="," close=")">
             #{item.id}
         </foreach>
     </select>
@@ -327,7 +329,7 @@
     <select id="countByCompanyListAndPopedom" resultType="Long">
         select count(*) from base_person_info where del_flag = 0
         and popedom_ like #{type}
-
+        and guest_enabled is not true
         <foreach collection="list" index="index" item="item" open="and company_id in(" separator="," close=")">
             #{item.id}
         </foreach>
@@ -335,6 +337,7 @@
 
     <select id="countStudentByCompanyListAndPopedom" resultType="Long">
         select count(*) from base_person_info where del_flag = 0
+        and guest_enabled is not true
         and popedom_ = #{type}
         <foreach collection="list" index="index" item="item" open="and company_id in(" separator="," close=")">
             #{item.id}
@@ -368,5 +371,12 @@
                 ]]>
 
 
+</select>
+    <select id="notGuestList" resultMap="PersonInfoMap">
+        <![CDATA[
+        select * from base_person_info where del_flag = 0
+                and guest_enabled is not true
+        ]]>
+
 </select>
 </mapper>

+ 26 - 12
web/src/main/java/com/jpsoft/smart/modules/base/controller/DeviceInfoController.java

@@ -1,21 +1,14 @@
 package com.jpsoft.smart.modules.base.controller;
 
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.Page;
-import com.jpsoft.smart.modules.base.entity.AlarmInfo;
 import com.jpsoft.smart.modules.base.entity.CompanyDeviceRelation;
 import com.jpsoft.smart.modules.base.service.CompanyDeviceRelationService;
-import com.jpsoft.smart.modules.common.utils.LApiUtil;
 import com.jpsoft.smart.modules.common.utils.PojoUtils;
 import com.jpsoft.smart.modules.common.dto.Sort;
 import com.jpsoft.smart.modules.common.dto.MessageResult;
 import com.jpsoft.smart.modules.base.entity.DeviceInfo;
 import com.jpsoft.smart.modules.base.service.DeviceInfoService;
 import com.jpsoft.smart.modules.lapi.service.ILapiService;
-import com.jpsoft.smart.modules.lapi.vo.LapiMsgResult;
-import com.jpsoft.smart.modules.lapi.vo.LapiResult;
 import com.jpsoft.smart.modules.sys.entity.User;
 import com.jpsoft.smart.modules.sys.service.DataDictionaryService;
 import com.jpsoft.smart.modules.sys.service.UserService;
@@ -24,9 +17,6 @@ import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.poi.hssf.usermodel.HSSFCell;
-import org.apache.poi.hssf.usermodel.HSSFRow;
-import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -34,9 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 import org.springframework.web.bind.annotation.*;
 
-import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
 import java.util.*;
 
 @RestController
@@ -544,4 +532,30 @@ public class DeviceInfoController {
     }
 
 
+
+    @ApiOperation(value = "查询")
+    @RequestMapping(value = "query", method = RequestMethod.POST)
+    public MessageResult<List> query(
+            String aliasName,
+            @RequestParam(value = "limit", defaultValue = "20") int limit,
+            @RequestAttribute String subject) {
+        MessageResult<List> msgResult = new MessageResult<>();
+
+        Map<String, Object> searchParams = new HashMap<>();
+
+        List<Sort> sortList = new ArrayList<>();
+        sortList.add(new Sort("a.is_online","desc"));
+        sortList.add(new Sort("a.create_time","desc"));
+
+        if (StringUtils.isNotEmpty(aliasName)) {
+            searchParams.put("aliasName", "%" + aliasName + "%");
+        }
+        List<DeviceInfo> deviceList = deviceInfoService.pageSearch(searchParams,1, limit,false, sortList);
+
+        msgResult.setResult(true);
+        msgResult.setData(deviceList);
+
+        return msgResult;
+    }
+
 }

+ 1 - 1
web/src/main/java/com/jpsoft/smart/modules/base/controller/HomePageController.java

@@ -71,7 +71,7 @@ public class HomePageController {
             Integer totalAbnormalNum = 0;
             if (userService.hasRole(subject, "SYSADMIN")) {
                 companyNum = companyInfoService.list().size();
-                personNum = personInfoService.list().size();
+                personNum = personInfoService.notGuestList().size();
                 Integer normalDaysNum =  totalCheckCompanyService.findMinNormalDay();
                 normalDays = normalDaysNum==null?0:normalDaysNum;
                 Integer num = checkNumCompanyService.getDayCheckNum(DateUtil.format(new Date(), "yyyy-MM-dd"));

+ 54 - 56
web/src/main/java/com/jpsoft/smart/modules/base/controller/PersonDeviceRelationController.java

@@ -95,7 +95,7 @@ public class PersonDeviceRelationController {
                 personDeviceRelation.setDelFlag(false);
                 personDeviceRelation.setCreateBy(subject);
                 personDeviceRelation.setCreateTime(new Date());
-                personDeviceRelation.setIsBound(true);//绑定设备默认true
+                personDeviceRelation.setIsBound(false);//绑定设备默认true
 
                 affectCount = personDeviceRelationService.insert(personDeviceRelation);
             }
@@ -105,24 +105,24 @@ public class PersonDeviceRelationController {
                 //往设备库传输人脸信息
                 PersonInfo personInfo = personInfoService.get(personDeviceRelation.getPersonId());
                 //如果人员照片不为空
-                //if(StringUtils.isNotEmpty(personInfo.getFaceImageUrl())){
-
-                DeviceInfo deviceInfo = deviceInfoService.get(personDeviceRelation.getDeviceId());
-                if(!deviceInfo.getIsOnline()){
-                    throw new Exception("无法绑定,设备不在线!" );
-                }
-                List<LapiResult> lapiResults = lapiService.addPersonForDeviceIds(personDeviceRelation.getPersonId(),personDeviceRelation.getDeviceId());
-                for (int i = 0; i < lapiResults.size(); i++) {
-                    LapiResult lapiMsgResult = lapiResults.get(i);
-                    if (lapiMsgResult.isSuccess()) {
-                        msgResult.setResult(true);
-                    }else{
-                        throw new Exception("添加失败:" + lapiMsgResult.getMsg());
+                if(StringUtils.isNotEmpty(personInfo.getFaceImageUrl())){
+                    DeviceInfo deviceInfo = deviceInfoService.get(personDeviceRelation.getDeviceId());
+                    if(!deviceInfo.getIsOnline()){
+                        throw new Exception("无法绑定,设备不在线!" );
                     }
-                }
-                //}else{
+                    List<LapiResult> lapiResults = lapiService.addPersonForDeviceIds(personDeviceRelation.getPersonId(),personDeviceRelation.getDeviceId());
+                    for (int i = 0; i < lapiResults.size(); i++) {
+                        LapiResult lapiMsgResult = lapiResults.get(i);
+                        if (lapiMsgResult.isSuccess()) {
+                            msgResult.setResult(true);
+                        }else{
+                            throw new Exception("添加失败:" + lapiMsgResult.getMsg());
+                        }
+                    }
+                }else{
                     //throw new Exception("添加失败:人员没有上传照片" );
-                //}
+                    //没有照片 可以只进行数据绑定 不进行设备操作
+                }
                 msgResult.setResult(true);
                 msgResult.setData(personDeviceRelation);
             } else {
@@ -169,7 +169,7 @@ public class PersonDeviceRelationController {
                        item.setDelFlag(false);
                        item.setCreateBy(subject);
                        item.setCreateTime(new Date());
-                       item.setIsBound(true);//绑定设备默认true
+                       item.setIsBound(false);//绑定设备默认false
 
                        affectCount += personDeviceRelationService.insert(item);
                    }
@@ -183,43 +183,41 @@ public class PersonDeviceRelationController {
                 //往设备库传输人脸信息
                 PersonInfo personInfo = personInfoService.get(personId);
                 //如果人员照片不为空
-                //if(StringUtils.isNotEmpty(personInfo.getFaceImageUrl())) {
-                List<LapiResult> lapiResults = lapiService.addPerson(personId);
-                for (int i = 0; i < lapiResults.size(); i++) {
-                    LapiResult lapiResult = lapiResults.get(i);
-                    if (lapiResult.isSuccess()) {
-                        msgResult.setResult(true);
-                    } else {
-                        String personName = "";
-                        if (personInfo != null) {
-                            personName = personInfo.getName();
+                if(StringUtils.isNotEmpty(personInfo.getFaceImageUrl())) {
+                    List<LapiResult> lapiResults = lapiService.addPerson(personId);
+                    for (int i = 0; i < lapiResults.size(); i++) {
+                        LapiResult lapiResult = lapiResults.get(i);
+                        if (lapiResult.isSuccess()) {
+                            msgResult.setResult(true);
+                        } else {
+                            String personName = "";
+                            if (personInfo != null) {
+                                personName = personInfo.getName();
+                            }
+                            Map resultMap = (Map) lapiResult.getData();
+                            HSSFRow row = sheet.createRow(sheet.getLastRowNum() + 1);
+                            HSSFCell cell1 = row.createCell(0);
+                            cell1.setCellValue(personName);
+                            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());
+
+                            //删除绑定关系
+                            PersonDeviceRelation personDeviceRelation = personDeviceRelationService.findByDeviceIdAndPersonId(resultMap.get("deviceId").toString(), personId);
+                            personDeviceRelation.setDelFlag(true);
+                            personDeviceRelation.setUpdateBy(subject);
+                            personDeviceRelation.setUpdateTime(new Date());
+                            personDeviceRelation.setIsBound(false);
+
+                            personDeviceRelationService.update(personDeviceRelation);
+                            addCount++;
                         }
-                        Map resultMap = (Map) lapiResult.getData();
-                        HSSFRow row = sheet.createRow(sheet.getLastRowNum() + 1);
-                        HSSFCell cell1 = row.createCell(0);
-                        cell1.setCellValue(personName);
-                        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());
-
-                        //删除绑定关系
-                        PersonDeviceRelation personDeviceRelation = personDeviceRelationService.findByDeviceIdAndPersonId(resultMap.get("deviceId").toString(), personId);
-                        personDeviceRelation.setDelFlag(true);
-                        personDeviceRelation.setUpdateBy(subject);
-                        personDeviceRelation.setUpdateTime(new Date());
-                        personDeviceRelation.setIsBound(false);
-
-                        personDeviceRelationService.update(personDeviceRelation);
-                        addCount++;
                     }
                 }
-                //}
 //
-
-
                 if(addCount > 0){
                     //异常数量大于0,表示有部分数据同步失败
                     msgResult.setResult(false);
@@ -288,15 +286,15 @@ public class PersonDeviceRelationController {
                         item.setDelFlag(false);
                         item.setCreateBy(subject);
                         item.setCreateTime(new Date());
-                        item.setIsBound(true);//绑定设备默认true
+                        item.setIsBound(false);//绑定设备默认false
 
                         affectCount += personDeviceRelationService.insert(item);
                         //往设备库传输人脸信息
                         //批量操作
 
-//                        PersonInfo personInfo = personInfoService.get(personId);
+                        PersonInfo personInfo = personInfoService.get(personId);
 //                        //如果人员照片为空
-//                        if(StringUtils.isEmpty(personInfo.getFaceImageUrl())){
+                        if(StringUtils.isEmpty(personInfo.getFaceImageUrl())){
 //                            HSSFRow row = sheet.createRow(sheet.getLastRowNum() + 1);
 //                            HSSFCell cell1 = row.createCell(0);
 //                            cell1.setCellValue(personInfo.getName());
@@ -312,8 +310,8 @@ public class PersonDeviceRelationController {
 //                            item.setUpdateBy(subject);
 //                            item.setUpdateTime(new Date());
 //                            personDeviceRelationService.update(item);
-//                            continue;
-//                        }
+                            continue;
+                        }
 
                         List<LapiResult> lapiResults = lapiService.addPersonForDeviceIds(personId,deviceId);
 

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

@@ -1103,7 +1103,7 @@ public class PersonInfoController {
 //            }
 //            else{
 //                searchParams.put("companyId",user.getCompanyId());
-//            }
+//
             if (StringUtils.isNotEmpty(position1)) {
                 searchParams.put("position1","%" + position1 + "%");
             }