Browse Source

Merge branch 'V1' of http://223.75.76.159:9090/xiao547607/smart-community-server

fllmoyu 5 years ago
parent
commit
352865ec92

+ 2 - 5
common/src/main/java/com/jpsoft/smart/modules/base/dao/PersonDeviceFilterLogDAO.java

@@ -1,11 +1,8 @@
 package com.jpsoft.smart.modules.base.dao;
 import com.github.pagehelper.Page;
-import com.jpsoft.smart.modules.base.entity.CompanyInfo;
+import com.jpsoft.smart.modules.base.entity.*;
 import org.apache.ibatis.annotations.Param;
 
-import com.jpsoft.smart.modules.base.entity.PersonDeviceFilterLog;
-import com.jpsoft.smart.modules.base.entity.PersonDeviceLog;
-import com.jpsoft.smart.modules.base.entity.PersonInfo;
 import com.jpsoft.smart.modules.common.dto.Sort;
 import org.springframework.stereotype.Repository;
 
@@ -60,7 +57,7 @@ public interface PersonDeviceFilterLogDAO {
 
     Integer countDetectedByCompanyId(String companyId, Date startDate, Date endDate);
 
-    long countUndetectedByCompanyCode(String companyCode,Long personId, Date startTime, Date endTime);
+    long countUndetectedByCompanyCode(String companyCode, List<PersonCompany> personCompanyList, Date startTime, Date endTime);
 
     List<PersonInfo> findUndetectedByCompanyCode(@Param("searchParams") Map<String, Object> searchParams);
 

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

@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateTime;
 import cn.hutool.json.JSONObject;
 import com.github.pagehelper.Page;
 import com.jpsoft.smart.modules.base.entity.CompanyInfo;
+import com.jpsoft.smart.modules.base.entity.PersonCompany;
 import com.jpsoft.smart.modules.base.entity.PersonDeviceFilterLog;
 import com.jpsoft.smart.modules.base.entity.PersonInfo;
 import com.jpsoft.smart.modules.common.dto.Sort;
@@ -60,7 +61,7 @@ public interface PersonDeviceFilterLogService {
      * @return
      */
     long countByTimeRangeAndCompanyCode(String companyCode,Long personId,int status,float temperatureMax,Date startTime, Date endTime);
-    long countUndetectedByCompanyCode(String companyCode,Long personId, Date startTime, Date endTime);
+    long countUndetectedByCompanyCode(String companyCode, List<PersonCompany> personCompanyList, Date startTime, Date endTime);
 
     Integer getDayAbnormalNum(Date startTime, Date endTime);
 

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

@@ -242,8 +242,8 @@ public class PersonDeviceFilterLogServiceImpl implements PersonDeviceFilterLogSe
     }
 
     @Override
-    public long countUndetectedByCompanyCode(String companyCode, Long personId, Date startTime, Date endTime) {
-        return personDeviceFilterLogDAO.countUndetectedByCompanyCode(companyCode, personId, startTime, endTime);
+    public long countUndetectedByCompanyCode(String companyCode, List<PersonCompany> personCompanyList, Date startTime, Date endTime) {
+        return personDeviceFilterLogDAO.countUndetectedByCompanyCode(companyCode, personCompanyList, startTime, endTime);
     }
 
     @Override

+ 3 - 0
common/src/main/resources/mapper/base/CompanyInfo.xml

@@ -147,6 +147,9 @@
             <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}

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

@@ -296,10 +296,15 @@
         ]]>
         and (
             b.code_ like #{companyCode}
-        <if test="personId!=null">
+<!--        <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=")">
+                #{item.companyId}
+            </foreach>
         </if>
         )
     </select>
@@ -382,10 +387,15 @@
         ]]>
         and (
         b.code_ like #{searchParams.companyCode}
-        <if test="searchParams.personId!=null">
+<!--        <if test="personId!=null">
             or b.id_ in (
-                select d.company_id from base_person_company d where d.person_id = #{searchParams.personId}
+            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=")">
+                #{item.companyId}
+            </foreach>
         </if>
         )
         order by a.id_ asc

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

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

+ 20 - 1
lapi/src/main/java/com/jpsoft/smart/lapi/handler/PersonVerificationHandler.java

@@ -6,6 +6,8 @@ import com.jpsoft.smart.modules.base.service.PersonDeviceFilterLogService;
 import com.jpsoft.smart.modules.base.service.PersonDeviceLogService;
 import com.jpsoft.smart.modules.business.service.WorkAttendanceService;
 import com.jpsoft.smart.modules.common.utils.LApiUtil;
+import com.jpsoft.smart.modules.sys.entity.SysLog;
+import com.jpsoft.smart.modules.sys.service.SysLogService;
 import io.netty.channel.ChannelHandler;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.SimpleChannelInboundHandler;
@@ -19,6 +21,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.math.BigDecimal;
+import java.net.SocketAddress;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.HashMap;
@@ -37,9 +40,13 @@ public class PersonVerificationHandler extends SimpleChannelInboundHandler<Perso
     @Autowired
     private WorkAttendanceService workAttendanceService;
 
+    @Autowired
+    private SysLogService sysLogService;
+
     @Override
-    protected void channelRead0(ChannelHandlerContext channelHandlerContext, PersonVerification personVerification) throws Exception {
+    protected void channelRead0(ChannelHandlerContext ctx, PersonVerification personVerification) throws Exception {
         log.warn("人员记录");
+
         JSONObject jsonObject = personVerification.getJsonObject();
 
         log.warn(jsonObject.toString());
@@ -88,6 +95,18 @@ public class PersonVerificationHandler extends SimpleChannelInboundHandler<Perso
         map.put("matchPersonInfo",matchPersonInfo);
         log.warn(map.toString());
 
+        new Thread(()->{
+            SysLog sysLog = new SysLog();
+            sysLog.setPointcut(deviceNo);
+            sysLog.setUrl("/LAPI/V1.0/System/Event/Notification/PersonVerification");
+            sysLog.setData(map.toString());
+            sysLog.setRemark("收到人脸识别信息");
+            SocketAddress remoteAddress = ctx.channel().remoteAddress();
+            sysLog.setRemoteIp(remoteAddress.toString());
+            sysLog.setCreateTime(new Date());
+            sysLogService.insert(sysLog);
+        }).start();
+
         //记录人员记录
         personDeviceLogService.deviceInsertLog(deviceNo,temperature,faceImageJson,libMatInfoListJson,matchPersonInfo,date,maskFlag);
 

+ 25 - 0
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,6 +434,7 @@ 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 = "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"),
@@ -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 + "%");
         }

+ 17 - 3
web/src/main/java/com/jpsoft/smart/modules/mobile/controller/PersonDeviceLogApiController.java

@@ -57,6 +57,9 @@ public class PersonDeviceLogApiController {
     @Autowired
     private ValueOperations<String, Object> valueOperations;
 
+    @Autowired
+    private PersonCompanyService personCompanyService;
+
     @PostMapping("queryTemperatureRawRecordList")
     @ApiOperation(value="根据实时数据查看企业人员温度数据")
     @ApiImplicitParams({
@@ -489,7 +492,9 @@ public class PersonDeviceLogApiController {
             long abnormalCount = personDeviceFilterLogService.countByTimeRangeAndCompanyCode(companyInfo.getCode() + "%",personInfo.getId(),
                     -1,temperatureConfig.getMax(),startTime,endTime);
 
-            long undetectedCount = personDeviceFilterLogService.countUndetectedByCompanyCode(companyInfo.getCode() + "%",personInfo.getId(),
+            List<PersonCompany> personCompanyList = personCompanyService.findByPersonId(personInfo.getId());
+
+            long undetectedCount = personDeviceFilterLogService.countUndetectedByCompanyCode(companyInfo.getCode() + "%",personCompanyList,
                     startTime,endTime);
 
             Map<String,Object> map1 = new HashMap();
@@ -639,7 +644,9 @@ public class PersonDeviceLogApiController {
                 }
             }
 
-            long undetectedCount = personDeviceFilterLogService.countUndetectedByCompanyCode(companyInfo.getCode() + "%",personInfo.getId(),startTime,endTime);
+            List<PersonCompany> personCompanyList = personCompanyService.findByPersonId(personInfo.getId());
+
+            long undetectedCount = personDeviceFilterLogService.countUndetectedByCompanyCode(companyInfo.getCode() + "%",personCompanyList,startTime,endTime);
 
             map.put("companyTotalCount",companyTotalCount);
             map.put("personTotalCount",personTotalCount);
@@ -653,6 +660,8 @@ public class PersonDeviceLogApiController {
         catch (Exception ex){
             msgResult.setMessage(ex.getMessage());
             msgResult.setResult(false);
+
+            log.error(ex.getMessage(),ex);
         }
 
         return msgResult;
@@ -693,7 +702,12 @@ public class PersonDeviceLogApiController {
 
             Map<String,Object> searchParams = new HashMap<>();
             searchParams.put("companyCode",companyInfo.getCode() + "%");
-            searchParams.put("personId",personInfo.getId());
+//            searchParams.put("personId",personInfo.getId());
+
+            List<PersonCompany> personCompanyList = personCompanyService.findByPersonId(personInfo.getId());
+
+            searchParams.put("personCompanyList",personCompanyList);
+
             searchParams.put("startTime",startTime);
             searchParams.put("endTime",endTime);
 

+ 9 - 4
web/src/main/java/com/jpsoft/smart/modules/mobile/controller/PersonInfoApiController.java

@@ -203,15 +203,20 @@ public class PersonInfoApiController {
 
                         if (personCompanies.size() > 0) {
                             CompanyInfo companyInfo = companyInfoService.get(personCompanies.get(0).getCompanyId());
-                            selectedCompany = companyInfo;
+
+                            if(companyInfo!=null) {
+                                selectedCompany = companyInfo;
+                            }
                         }
                     }
                 }
 
-                companyMap.put("id",selectedCompany.getId());
-                companyMap.put("name",selectedCompany.getName());
+                if(selectedCompany!=null) {
+                    companyMap.put("id", selectedCompany.getId());
+                    companyMap.put("name", selectedCompany.getName());
 
-                valueOperations.set(RedisConfig.PERSON_SELECT_COMPANY + personInfo.getId(), companyMap,2,TimeUnit.HOURS);
+                    valueOperations.set(RedisConfig.PERSON_SELECT_COMPANY + personInfo.getId(), companyMap, 2, TimeUnit.HOURS);
+                }
             }
 
             dataMap.put("company",companyMap);

+ 1 - 1
web/src/main/resources/application-production.yml

@@ -8,7 +8,7 @@ spring:
 #    url: jdbc:log4jdbc:mysql://127.0.0.1:3306/smart-community?autoReconnect=true&characterEncoding=utf8&serverTimezone=GMT%2B8
 #    username: root
 #    password: slgo^Root_!Q@W#E)P(O*I
-    url: jdbc:log4jdbc:mysql://rm-bp1k37vutg1096q45do.mysql.rds.aliyuncs.com:3306/smart?autoReconnect=true&characterEncoding=utf8&serverTimezone=GMT%2B8
+    url: jdbc:log4jdbc:mysql://rm-bp1k37vutg1096q45do.mysql.rds.aliyuncs.com:3306/smart-community?autoReconnect=true&characterEncoding=utf8&serverTimezone=GMT%2B8
     username: smart
     password: smart_123
   devtools: