Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/master'

wxg 3 gadi atpakaļ
vecāks
revīzija
20ccc8eb43

+ 15 - 1
src/main/java/com/yx/face/controller/TBFaceController.java

@@ -123,8 +123,8 @@ public class TBFaceController {
     @ApiOperation("上报任务结果处理")
     @PostMapping("pushTaskResult")
     public Map<String, Object> pushTaskResult(HttpServletRequest request) {
-
         try {
+
             return faceTBService.pushTaskResult(getParam(request));
         } catch (Exception e) {
             log.info("上报任务结果处理 异常={}", e.getMessage());
@@ -134,6 +134,20 @@ public class TBFaceController {
         return result;
     }
 
+//
+//    @ApiOperation("批量上传人员")
+//    @PostMapping("syncUsers")
+//    public Map<String, Object> syncUsers(HttpServletRequest request) {
+//        try {
+//            return faceTBService.syncUsers(new HashMap<>());
+//        } catch (Exception e) {
+//            log.info("上报任务结果处理 异常={}", e.getMessage());
+//        }
+//        Map<String, Object> result = Maps.newHashMapWithExpectedSize(1);
+//        result.put("errCode", "00");
+//        return result;
+//    }
+
     @ApiOperation("获取任务ID")
     @PostMapping("getTaskId")
     public Map<String, Object> getTaskId(HttpServletRequest request) {

+ 11 - 0
src/main/java/com/yx/face/dao/UserControlEarlyWarningListDao.java

@@ -2,7 +2,9 @@ package com.yx.face.dao;
 
 import com.yx.face.boot.component.tk.TKMapper;
 import com.yx.face.model.entity.UserControlEarlyWarningList;
+import com.yx.face.model.vo.AdminAndUserEarlyWarningVO;
 import com.yx.face.model.vo.UserControlEarlyWarningVO;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 import java.util.Map;
@@ -18,4 +20,13 @@ import java.util.Map;
 public interface UserControlEarlyWarningListDao extends TKMapper<UserControlEarlyWarningList> {
     /*分页查询预警人员列表*/
     List<UserControlEarlyWarningVO> getPageList(Map<String, Object> map);
+
+    /**
+     *
+     * @param deviceSn 设备编号
+     * @param idNumber  身份证
+     * @param isControlEarlyWarning 是否开启 1 开启2 否
+     * @return
+     */
+    AdminAndUserEarlyWarningVO getAdminWarningInformation(@Param("deviceSn") String deviceSn, @Param("idNumber") String idNumber, @Param("isControlEarlyWarning") Integer isControlEarlyWarning);
 }

+ 16 - 3
src/main/java/com/yx/face/model/entity/UserControlEarlyWarningListLog.java

@@ -57,10 +57,23 @@ public class UserControlEarlyWarningListLog{
     @Column(name = "face_log_id")
     private Long faceLogId;
 
+
+    /**
+     * 布控人名称
+     */
+    @Column(name = "control_name")
+    private String controlName;
+
+    /**
+     * 布控人电话
+     */
+    @Column(name = "control_phone")
+    private String controlPhone;
+
     /**
-     * 预警人员id
+     * 布控人单位
      */
-    @Column(name = "control_early_warning_id")
-    private Long controlEarlyWarningId;
+    @Column(name = "control_unit")
+    private String controlUnit;
 
 }

+ 31 - 0
src/main/java/com/yx/face/model/vo/AdminAndUserEarlyWarningVO.java

@@ -0,0 +1,31 @@
+package com.yx.face.model.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+
+/**
+ * @description:
+ * @ClassName UserVisitorListVO
+ * @Author cmc
+ * @Date 2021/11/5 14:23
+ */
+@ApiModel("预警信息 model")
+@Data
+public class AdminAndUserEarlyWarningVO {
+
+
+
+    @ApiModelProperty(value = "布控人单位")
+    private String controlUnit;
+
+    @ApiModelProperty(value = "布控人手机号")
+    private String controlPhone;
+
+    @ApiModelProperty(value = "布控人姓名")
+    private String controlName;
+
+    @ApiModelProperty(value = "布控人姓名")
+    private Integer adminId;
+}

+ 2 - 0
src/main/java/com/yx/face/service/FaceTBService.java

@@ -117,4 +117,6 @@ public interface FaceTBService {
     Map<String, Object> getTaskId(Map<String, Object> dto);
 
     void pushUsersOnline(List<Map<String, String>> list);
+
+//    Map<String, Object> syncUsers(Map<String, Object> param);
 }

+ 8 - 0
src/main/java/com/yx/face/service/UserControlEarlyWarningListService.java

@@ -31,4 +31,12 @@ public interface UserControlEarlyWarningListService{
 
     /*预警人员分页显示*/
     PageInfo<UserControlEarlyWarningVO> getPageList(RestDTO<UserControlEarlyWarningSearch> dto);
+
+    /**
+     *
+     * @param deviceSn 设备编号
+     * @param idNumber 身份证
+     * @param faceLogId 现场照片
+     */
+    void addWarningInformation(String deviceSn, String idNumber, Long faceLogId);
 }

+ 40 - 8
src/main/java/com/yx/face/service/impl/FaceTBServiceImpl.java

@@ -18,6 +18,7 @@ import com.yx.face.model.vo.SystemLongTermDocumentsVO;
 import com.yx.face.netty_client.NettyClient;
 import com.yx.face.service.FaceTBService;
 //import com.yx.face.service.SuKangMaAipService;
+import com.yx.face.service.UserControlEarlyWarningListService;
 import com.yx.face.service.feign.TBDeviceFaceService;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
@@ -33,6 +34,8 @@ import javax.persistence.Column;
 import java.util.*;
 import java.util.stream.Collectors;
 
+import static org.apache.coyote.http11.Constants.a;
+
 /**
  * @description: FaceTBServiceImpl <br>
  * @date: 2021/6/3 10:40 <br>
@@ -51,23 +54,26 @@ public class FaceTBServiceImpl implements FaceTBService {
     private UserInfoDao userInfoDao;
     @Resource
     private FaceLogDao faceLogDao;
-    @Resource
-    private SystemConfigDao systemConfigDao;
-    @Resource
-    private SystemLongTermDocumentsDao systemLongTermDocumentsDao;
+    //    @Resource
+//    private SystemConfigDao systemConfigDao;
+//    @Resource
+//    private SystemLongTermDocumentsDao systemLongTermDocumentsDao;
     @Autowired
     private AsyncTriggerRetryImpl asyncTriggerRetry;
     @Resource
     private FaceTaskDao faceTaskDao;
     @Autowired
     private TBDeviceFaceService tbDeviceFaceService;
+
     @Autowired
-    private RedisUtil redisUtil;
+    private UserControlEarlyWarningListService userControlEarlyWarningListService;
+    //    @Autowired
+//    private RedisUtil redisUtil;
     @Value("${web.address}")
     private String address;
-
-    @Autowired
-    private NettyClient nettyClient;
+//
+//    @Autowired
+//    private NettyClient nettyClient;
 
 //    @Autowired
 //    private TaskPoolConfig taskPoolConfig;
@@ -670,6 +676,8 @@ public class FaceTBServiceImpl implements FaceTBService {
             faceLog.setCreateTime(now);
             if (verifytype == 0 || verifytype == 2) {
                 faceLogDao.insertSelective(faceLog);
+                //预警数据插入
+                userControlEarlyWarningListService.addWarningInformation(faceLog.getDeviceSn(), faceLog.getCardid(), faceLog.getId());
             }
 //            Map<String, String> maps = new HashMap<>(1);
 //            maps.put("face-log", JSONObject.toJSONString(faceLog));
@@ -792,6 +800,30 @@ public class FaceTBServiceImpl implements FaceTBService {
 //        }
     }
 
+//    @Override
+//    public Map<String, Object> syncUsers(Map<String, Object> param) {
+//        ArrayList<Map<String, Object>> objects = new ArrayList<>();
+//        for (int i = 1; i <= 10000; i++) {
+//            Map<String, Object> dataItem = Maps.newHashMapWithExpectedSize(8);
+//            // 下发参数
+//            dataItem.put("pin", i);
+//            dataItem.put("name", "张三" + i);
+//            dataItem.put("validPeriodStart", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
+//            dataItem.put("validPeriodEnd", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
+//            dataItem.put("userType", 0);
+//            dataItem.put("photo", "https://files.jiandaoyun.com/FnGKTV33Vq3Re-XPfE3FtZNvK-fV?attname=FnGKTV33Vq3Re-XPfE3FtZNvK-fV.jpeg&e=1642262399&token=bM7UwVPyBBdPaleBZt21SWKzMylqPUpn-05jZlas:Xyg_TpATKLBAFiJX_YmhBa79vEE=");
+//            dataItem.put("rightno", 105);
+//            dataItem.put("cardid", "412728199706030513");
+//            objects.add(dataItem);
+//        }
+//        Map map = new HashMap();
+//        map.put("errCode", "00");
+//        map.put("totalNum", "3");
+//        map.put("updateTime", "11");
+//        map.put("data", objects);
+//        return map;
+//    }
+
 
     @Async
     public void faceDeviceList(FaceDevice faceDevice, SystemLongTermDocumentsVO vo) {

+ 50 - 12
src/main/java/com/yx/face/service/impl/UserControlEarlyWarningListServiceImpl.java

@@ -8,19 +8,24 @@ import com.yx.face.boot.restful.RestResult;
 import com.yx.face.boot.restful.ServiceException;
 import com.yx.face.boot.uitls.SMSOrIdCardUtils;
 import com.yx.face.dao.UserControlEarlyWarningListDao;
+import com.yx.face.dao.UserControlEarlyWarningListLogDao;
 import com.yx.face.model.dto.UserControlEarlyWarningDTO;
 import com.yx.face.model.dto.UserWhitelistDTO;
 import com.yx.face.model.entity.UserControlEarlyWarningList;
+import com.yx.face.model.entity.UserControlEarlyWarningListLog;
 import com.yx.face.model.excel.UserControlEarlyWarningExcel;
 import com.yx.face.model.excel.UserWhitelistExcel;
 import com.yx.face.model.search.UserControlEarlyWarningSearch;
+import com.yx.face.model.vo.AdminAndUserEarlyWarningVO;
 import com.yx.face.model.vo.AdminVO;
 import com.yx.face.model.vo.FaceLogVO;
 import com.yx.face.model.vo.UserControlEarlyWarningVO;
 import com.yx.face.service.AdminService;
 import com.yx.face.service.UserControlEarlyWarningListService;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -39,47 +44,50 @@ public class UserControlEarlyWarningListServiceImpl implements UserControlEarlyW
 
     @Resource
     private UserControlEarlyWarningListDao userControlEarlyWarningListDao;
+    @Resource
+    private UserControlEarlyWarningListLogDao userControlEarlyWarningListLogDao;
 
     @Autowired
     private AdminService adminService;
 
     @Override
     public Integer addOrUpdate(UserControlEarlyWarningDTO userControlEarlyWarningDTO) {
-        if(!SMSOrIdCardUtils.isIdCard(userControlEarlyWarningDTO.getEarlyWarningIdNumber()))
-        throw new ServiceException("请输入正确的预警人员身份证号");
+        if (!SMSOrIdCardUtils.isIdCard(userControlEarlyWarningDTO.getEarlyWarningIdNumber()))
+            throw new ServiceException("请输入正确的预警人员身份证号");
 
         Date date = new Date();
         UserControlEarlyWarningList ucewl = new UserControlEarlyWarningList();
-        BeanUtils.copyProperties(userControlEarlyWarningDTO,ucewl);
+        BeanUtils.copyProperties(userControlEarlyWarningDTO, ucewl);
         ucewl.setUpdateTime(date);
-        if(userControlEarlyWarningDTO.getId() == null){
+        if (userControlEarlyWarningDTO.getId() == null) {
             UserControlEarlyWarningList u = new UserControlEarlyWarningList();
             u.setEarlyWarningIdNumber(userControlEarlyWarningDTO.getEarlyWarningIdNumber());
             u.setAdminId(userControlEarlyWarningDTO.getAdminId());
             UserControlEarlyWarningList userControlEarlyWarningList = userControlEarlyWarningListDao.selectOne(u);
-            if(userControlEarlyWarningList != null)throw new ServiceException("该预警人员已经添加到该账号下了");
+            if (userControlEarlyWarningList != null) throw new ServiceException("该预警人员已经添加到该账号下了");
 
             ucewl.setCreateTime(date);
             return userControlEarlyWarningListDao.insertSelective(ucewl);
-        }else {
-            UserControlEarlyWarningList userControlEarlyWarningList = userControlEarlyWarningListDao.selectByPrimaryKey(userControlEarlyWarningDTO.getId());
-            if(!userControlEarlyWarningList.getEarlyWarningIdNumber().equals(userControlEarlyWarningDTO.getEarlyWarningIdNumber()))
-                throw new ServiceException("预警人员身份照号不可修改");
+        } else {
+//            UserControlEarlyWarningList userControlEarlyWarningList = userControlEarlyWarningListDao.selectByPrimaryKey(userControlEarlyWarningDTO.getId());
+//            if(!userControlEarlyWarningList.getEarlyWarningIdNumber().equals(userControlEarlyWarningDTO.getEarlyWarningIdNumber()))
+//                throw new ServiceException("预警人员身份照号不可修改");
             ucewl.setId(userControlEarlyWarningDTO.getId());
             return userControlEarlyWarningListDao.updateByPrimaryKeySelective(ucewl);
         }
     }
 
     @Override
-    public RestResult<List<String>> userControlEarlyWarningListExcel(List<Object> datas,Integer adminId) {
+    public RestResult<List<String>> userControlEarlyWarningListExcel(List<Object> datas, Integer adminId) {
         List<String> list = new ArrayList<>();
         for (int i = 0; i < datas.size(); i++) {
             try {
                 UserControlEarlyWarningExcel ucewe = (UserControlEarlyWarningExcel) datas.get(i);
-                if (ucewe.getEarlyWarningIdNumber() == null) throw new ServiceException("第" + (i + 2) + "行,预警人员身份证号不能为空");
+                if (ucewe.getEarlyWarningIdNumber() == null)
+                    throw new ServiceException("第" + (i + 2) + "行,预警人员身份证号不能为空");
 
                 UserControlEarlyWarningDTO userControlEarlyWarningDTO = new UserControlEarlyWarningDTO();
-                BeanUtils.copyProperties(ucewe,userControlEarlyWarningDTO);
+                BeanUtils.copyProperties(ucewe, userControlEarlyWarningDTO);
                 userControlEarlyWarningDTO.setAdminId(adminId);
                 try {
                     this.addOrUpdate(userControlEarlyWarningDTO);
@@ -111,4 +119,34 @@ public class UserControlEarlyWarningListServiceImpl implements UserControlEarlyW
         List<UserControlEarlyWarningVO> list = userControlEarlyWarningListDao.getPageList(map);
         return new PageInfo<>(list);
     }
+
+    /**
+     * 插入匹配人员预警信息
+     *
+     * @param deviceSn 设备编号
+     * @param idNumber 身份证
+     * @param faceLogId  进出记录id
+     */
+    @Async
+    @Override
+    public void addWarningInformation(String deviceSn, String idNumber, Long faceLogId) {
+        // null 代表未查到
+        AdminAndUserEarlyWarningVO adminAndUserEarlyWarningVO = userControlEarlyWarningListDao.getAdminWarningInformation(deviceSn, idNumber, 1);
+        if (adminAndUserEarlyWarningVO != null) {
+            System.out.println(adminAndUserEarlyWarningVO);
+            UserControlEarlyWarningListLog userControlEarlyWarningListLog = new UserControlEarlyWarningListLog();
+            Date date = new Date();
+            userControlEarlyWarningListLog.setUpdateTime(date);
+            userControlEarlyWarningListLog.setCreateTime(date);
+            userControlEarlyWarningListLog.setControlUnit(adminAndUserEarlyWarningVO.getControlUnit());
+            userControlEarlyWarningListLog.setControlPhone(adminAndUserEarlyWarningVO.getControlPhone());
+            userControlEarlyWarningListLog.setControlName(adminAndUserEarlyWarningVO.getControlName());
+            userControlEarlyWarningListLog.setAdminId(adminAndUserEarlyWarningVO.getAdminId());
+            userControlEarlyWarningListLog.setStatus(1);
+            userControlEarlyWarningListLog.setFaceLogId(faceLogId);
+            System.out.println(userControlEarlyWarningListLog);
+            userControlEarlyWarningListLogDao.insert(userControlEarlyWarningListLog);
+        }
+
+    }
 }

+ 10 - 0
src/main/resources/mapper/UserControlEarlyWarningListDao.xml

@@ -74,5 +74,15 @@
 
 
     </select>
+    <select id="getAdminWarningInformation" resultType="com.yx.face.model.vo.AdminAndUserEarlyWarningVO">
+        SELECT c.control_name as controlName , c.control_phone  as controlPhone ,c.control_unit  as controlUnit, c.admin_id as adminId  FROM face_device as a
+                          LEFT JOIN admin as b
+                                    on a.admin_id = b.id
+                          LEFT JOIN user_control_early_warning_list as c
+                                    on b.id  = c.admin_id
+        WHERE a.sn = #{deviceSn}
+          and c.early_warning_id_number = #{idNumber}
+          and b.is_control_early_warning = #{isControlEarlyWarning}
+    </select>
 
 </mapper>

+ 18 - 21
src/main/resources/mapper/UserControlEarlyWarningListLogDao.xml

@@ -29,14 +29,13 @@
             b.`name` AS `name`,
             b.cardid AS idNumber,
             b.photo,
-            d.control_unit AS controlUnit,
-            d.control_phone AS controlPhone,
-            d.control_name AS controlName
+            a.control_unit AS controlUnit,
+            a.control_phone AS controlPhone,
+            a.control_name AS controlName
         FROM
             user_control_early_warning_list_log AS a
                 LEFT JOIN face_log AS b ON a.face_log_id = b.id
                 LEFT JOIN face_device AS c ON b.device_sn = c.sn
-                LEFT JOIN user_control_early_warning_list AS d ON a.control_early_warning_id = d.id
                 LEFT JOIN admin e on e.id =a.admin_id
         <where>
             and a.`status` = 1
@@ -69,15 +68,14 @@
         b.`name` AS `name`,
         b.cardid AS idNumber,
         b.photo,
-        d.control_unit AS controlUnit,
-        d.control_phone AS controlPhone,
-        d.control_name AS controlName,
+        a.control_unit AS controlUnit,
+        a.control_phone AS controlPhone,
+        a.control_name AS controlName,
         a.status
         FROM
         user_control_early_warning_list_log AS a
         LEFT JOIN face_log AS b ON a.face_log_id = b.id
         LEFT JOIN face_device AS c ON b.device_sn = c.sn
-        LEFT JOIN user_control_early_warning_list AS d ON a.control_early_warning_id = d.id
         LEFT JOIN admin e on e.id =a.admin_id
         <where>
             <if test="adminVo.type == 2">
@@ -108,13 +106,13 @@
             </if>
 
             <if test="qu.controlUnit != null and qu.controlUnit != '' ">
-                and d.control_unit like concat('%',#{qu.controlUnit},'%')
+                and a.control_unit like concat('%',#{qu.controlUnit},'%')
             </if>
             <if test="qu.controlPhone != null and qu.controlPhone != '' ">
-                and d.control_phone =#{qu.controlPhone}
+                and a.control_phone =#{qu.controlPhone}
             </if>
             <if test="qu.controlName != null and qu.controlName != '' ">
-                and d.control_name  like concat('%',#{qu.controlName},'%')
+                and a.control_name  like concat('%',#{qu.controlName},'%')
             </if>
             <if test="qu.startTime != null and qu.startTime != '' and qu.endTime != null and qu.endTime != '' ">
                 AND  <![CDATA[ b.face_time >= #{qu.startTime}]]>
@@ -134,15 +132,14 @@
         b.`name` AS `name`,
         b.cardid AS idNumber,
         b.photo,
-        d.control_unit AS controlUnit,
-        d.control_phone AS controlPhone,
-        d.control_name AS controlName,
+        a.control_unit AS controlUnit,
+        a.control_phone AS controlPhone,
+        a.control_name AS controlName,
         a.status
         FROM
         user_control_early_warning_list_log AS a
         LEFT JOIN face_log AS b ON a.face_log_id = b.id
         LEFT JOIN face_device AS c ON b.device_sn = c.sn
-        LEFT JOIN user_control_early_warning_list AS d ON a.control_early_warning_id = d.id
         LEFT JOIN admin e on e.id =a.admin_id
         <where>
             <if test="adminVo.type == 2">
@@ -160,26 +157,26 @@
                 and e.tag_id = #{adminVo.tagId}
             </if>
             <if test="adminVo.type == 5">
-                and e.id =#{adminVo.}
+                and e.id =#{adminVo.id}
             </if>
             <if test="qu.status != 0 ">
                 and a.status =#{qu.status}
             </if>
             <if test="qu.name != '' and qu.name != null ">
-                and d.early_warning_name =#{qu.name}
+                and b.name =#{qu.name}
             </if>
             <if test="qu.idNumber != '' and qu.idNumber != null ">
-                and d.early_warning_id_number =#{qu.idNumber}
+                and b.cardid =#{qu.idNumber}
             </if>
 
             <if test="qu.controlUnit != null and qu.controlUnit != '' ">
-                and d.control_unit like concat('%',#{qu.controlUnit},'%')
+                and a.control_unit like concat('%',#{qu.controlUnit},'%')
             </if>
             <if test="qu.controlPhone != null and qu.controlPhone != '' ">
-                and d.control_phone =#{qu.controlPhone}
+                and a.control_phone =#{qu.controlPhone}
             </if>
             <if test="qu.controlName != null and qu.controlName != '' ">
-                and d.control_name =#{qu.controlName}
+                and a.control_name =#{qu.controlName}
             </if>
             <if test="qu.startTime != null and qu.startTime != '' and qu.endTime != null and qu.endTime != '' ">
                 AND  <![CDATA[ b.face_time >= #{qu.startTime}]]>