张晓波
2023-10-12 c3e0c3ee12df1ffb544aa63c6c3a60486cbd1e40
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package com.thhy.staff.modules.biz.face.service.impl;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.thhy.general.utils.DeepCopyUtils;
import com.thhy.staff.config.EmqxConfig;
import com.thhy.staff.config.EmqxProperties;
import com.thhy.staff.modules.biz.face.entity.FaceDevice;
import com.thhy.staff.modules.biz.face.entity.FaceResult;
import com.thhy.staff.modules.biz.face.mapper.FaceDeviceMapper;
import com.thhy.staff.modules.biz.face.service.FaceServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
@Service
public class FaceServerImpl implements FaceServer {
 
    @Autowired
    private FaceDeviceMapper faceDeviceMapper;
 
    @Autowired
    private EmqxConfig emqxConfig;
 
    private Logger logger = LoggerFactory.getLogger(FaceServer.class);
 
    @Override
    public FaceResult login(String mess) {
        JSONObject jsonObject = JSONObject.parseObject(mess);
        FaceDevice faceDevice = JSON.toJavaObject(jsonObject,FaceDevice.class);
        int devCount = faceDeviceMapper.countByDevSn(faceDevice.getDevSno());
 
        if (devCount<1) {
            faceDeviceMapper.insert(faceDevice);
        }else{
            logger.info("设备"+faceDevice.getDevSno()+"已经存在");
        }
 
        FaceResult faceResult = new FaceResult(true,faceDevice,emqxConfig.toString());
        return faceResult;
    }
}