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; } }