|
@@ -14,10 +14,7 @@ import com.jpsoft.smart.modules.common.utils.LApiUtil;
|
|
import com.jpsoft.smart.modules.common.utils.OSSUtil;
|
|
import com.jpsoft.smart.modules.common.utils.OSSUtil;
|
|
import com.jpsoft.smart.modules.constant.LApiConstant;
|
|
import com.jpsoft.smart.modules.constant.LApiConstant;
|
|
import com.jpsoft.smart.modules.lapi.service.ILapiService;
|
|
import com.jpsoft.smart.modules.lapi.service.ILapiService;
|
|
-import com.jpsoft.smart.modules.lapi.vo.AddPersonVo;
|
|
|
|
-import com.jpsoft.smart.modules.lapi.vo.IdentificationVo;
|
|
|
|
-import com.jpsoft.smart.modules.lapi.vo.ImageVo;
|
|
|
|
-import com.jpsoft.smart.modules.lapi.vo.LapiMsgResult;
|
|
|
|
|
|
+import com.jpsoft.smart.modules.lapi.vo.*;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -62,12 +59,12 @@ public class LapiServiceImpl implements ILapiService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Boolean keepAlive(String id) throws Exception{
|
|
|
|
|
|
+ public Boolean keepAlive(String id) throws Exception {
|
|
DeviceInfo deviceInfo = deviceInfoService.get(id);
|
|
DeviceInfo deviceInfo = deviceInfoService.get(id);
|
|
- if (deviceInfo == null){
|
|
|
|
|
|
+ if (deviceInfo == null) {
|
|
throw new Exception("设备未绑定");
|
|
throw new Exception("设备未绑定");
|
|
}
|
|
}
|
|
- JSONObject jsonObject = LApiUtil.GetRequest(deviceInfo.getIpAddress()+":" + deviceInfo.getPort()+LApiConstant.KEEPALIVE);
|
|
|
|
|
|
+ JSONObject jsonObject = LApiUtil.GetRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.KEEPALIVE);
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -76,67 +73,67 @@ public class LapiServiceImpl implements ILapiService {
|
|
public List<LapiMsgResult> addPerson(Long id) throws Exception {
|
|
public List<LapiMsgResult> addPerson(Long id) throws Exception {
|
|
|
|
|
|
PersonInfo personInfo = personInfoService.get(id);
|
|
PersonInfo personInfo = personInfoService.get(id);
|
|
- if (personInfo == null){
|
|
|
|
|
|
+ if (personInfo == null) {
|
|
throw new Exception("人员不存在");
|
|
throw new Exception("人员不存在");
|
|
}
|
|
}
|
|
List<PersonDeviceRelation> listRelation = personDeviceRelationService.findByPersonId(id);
|
|
List<PersonDeviceRelation> listRelation = personDeviceRelationService.findByPersonId(id);
|
|
- if (listRelation.size()<=0){
|
|
|
|
|
|
+ if (listRelation.size() <= 0) {
|
|
throw new Exception("人员未绑定设备");
|
|
throw new Exception("人员未绑定设备");
|
|
}
|
|
}
|
|
CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
|
|
CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
|
|
List<DeviceInfo> deviceList = new ArrayList<>();
|
|
List<DeviceInfo> deviceList = new ArrayList<>();
|
|
- for (PersonDeviceRelation personDeviceRelation:listRelation){
|
|
|
|
|
|
+ for (PersonDeviceRelation personDeviceRelation : listRelation) {
|
|
DeviceInfo deviceInfo = deviceInfoService.get(personDeviceRelation.getDeviceId());
|
|
DeviceInfo deviceInfo = deviceInfoService.get(personDeviceRelation.getDeviceId());
|
|
- if (deviceInfo!=null && !deviceInfo.getDelFlag()){
|
|
|
|
|
|
+ if (deviceInfo != null && !deviceInfo.getDelFlag()) {
|
|
deviceList.add(deviceInfo);
|
|
deviceList.add(deviceInfo);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (deviceList.size()<=0){
|
|
|
|
|
|
+ if (deviceList.size() <= 0) {
|
|
throw new Exception("人员与设备绑定错误");
|
|
throw new Exception("人员与设备绑定错误");
|
|
}
|
|
}
|
|
List<LapiMsgResult> lapiMsgResults = new ArrayList<>();
|
|
List<LapiMsgResult> lapiMsgResults = new ArrayList<>();
|
|
- for (DeviceInfo deviceInfo : deviceList){
|
|
|
|
- HashMap<String,Object> map = new HashMap<>();
|
|
|
|
- map.put("Num",1L);
|
|
|
|
- HashMap<String,Object> map1 = new HashMap<>();
|
|
|
|
- map1.put("PersonID",personInfo.getId());
|
|
|
|
- map1.put("LastChange",new Date().getTime());
|
|
|
|
- map1.put("PersonCode",personInfo.getId().toString());
|
|
|
|
- map1.put("PersonName",personInfo.getName()+"_"+personInfo.getId().toString());
|
|
|
|
- map1.put("Remarks",companyInfo.getName());
|
|
|
|
|
|
+ for (DeviceInfo deviceInfo : deviceList) {
|
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
|
+ map.put("Num", 1L);
|
|
|
|
+ HashMap<String, Object> map1 = new HashMap<>();
|
|
|
|
+ map1.put("PersonID", personInfo.getId());
|
|
|
|
+ map1.put("LastChange", new Date().getTime());
|
|
|
|
+ map1.put("PersonCode", personInfo.getId().toString());
|
|
|
|
+ map1.put("PersonName", personInfo.getName() + "_" + personInfo.getId().toString());
|
|
|
|
+ map1.put("Remarks", companyInfo.getName());
|
|
|
|
|
|
//TimeTemplateNum 首字符必须大写
|
|
//TimeTemplateNum 首字符必须大写
|
|
- map1.put("TimeTemplateNum",0L);
|
|
|
|
|
|
+ map1.put("TimeTemplateNum", 0L);
|
|
|
|
|
|
- map1.put("IdentificationNum",1L);
|
|
|
|
- HashMap<String,Object> map2 = new HashMap<>();
|
|
|
|
|
|
+ map1.put("IdentificationNum", 1L);
|
|
|
|
+ HashMap<String, Object> map2 = new HashMap<>();
|
|
List listMap2 = new ArrayList();
|
|
List listMap2 = new ArrayList();
|
|
listMap2.add(map2);
|
|
listMap2.add(map2);
|
|
- map2.put("Type",0L);
|
|
|
|
- map2.put("Number",personInfo.getIdCard());
|
|
|
|
- map1.put("IdentificationList",listMap2);
|
|
|
|
- map1.put("ImageNum",1L);
|
|
|
|
-
|
|
|
|
- HashMap<String,Object> map3 = new HashMap<>();
|
|
|
|
- map3.put("FaceID",personInfo.getId());
|
|
|
|
- map3.put("Name",personInfo.getId()+".jpg");
|
|
|
|
- map3.put("Size",OSSUtil.downloadToBase64(personInfo.getFaceImageUrl()).length());
|
|
|
|
- map3.put("Data",OSSUtil.downloadToBase64(personInfo.getFaceImageUrl()));
|
|
|
|
|
|
+ map2.put("Type", 0L);
|
|
|
|
+ map2.put("Number", personInfo.getIdCard());
|
|
|
|
+ map1.put("IdentificationList", listMap2);
|
|
|
|
+ map1.put("ImageNum", 1L);
|
|
|
|
+
|
|
|
|
+ HashMap<String, Object> map3 = new HashMap<>();
|
|
|
|
+ map3.put("FaceID", personInfo.getId());
|
|
|
|
+ map3.put("Name", personInfo.getId() + ".jpg");
|
|
|
|
+ map3.put("Size", OSSUtil.downloadToBase64(personInfo.getFaceImageUrl()).length());
|
|
|
|
+ map3.put("Data", OSSUtil.downloadToBase64(personInfo.getFaceImageUrl()));
|
|
List listMap3 = new ArrayList();
|
|
List listMap3 = new ArrayList();
|
|
listMap3.add(map3);
|
|
listMap3.add(map3);
|
|
- map1.put("ImageList",listMap3);
|
|
|
|
|
|
+ map1.put("ImageList", listMap3);
|
|
List listMap1 = new ArrayList();
|
|
List listMap1 = new ArrayList();
|
|
listMap1.add(map1);
|
|
listMap1.add(map1);
|
|
- map.put("PersonInfoList",listMap1);
|
|
|
|
|
|
+ map.put("PersonInfoList", listMap1);
|
|
|
|
|
|
|
|
|
|
- try{
|
|
|
|
|
|
+ try {
|
|
//获取人员人脸库id
|
|
//获取人员人脸库id
|
|
- String faceDbId = getFaceDbId(deviceInfo,companyInfo.getName());
|
|
|
|
- JSONObject jsonObject = LApiUtil.PostRequest(deviceInfo.getIpAddress()+":"+deviceInfo.getPort()+LApiConstant.ADDPERSON+faceDbId+"/People",map);
|
|
|
|
|
|
+ String faceDbId = getFaceDbId(deviceInfo, companyInfo.getName());
|
|
|
|
+ JSONObject jsonObject = LApiUtil.PostRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.ADDPERSON + faceDbId + "/People", map);
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
- if (dataJson.getInteger("ResponseCode") ==0 && dataJson.getInteger("StatusCode") == 0){
|
|
|
|
|
|
+ if (dataJson.getInteger("ResponseCode") == 0 && dataJson.getInteger("StatusCode") == 0) {
|
|
LapiMsgResult lapiMsgResult = new LapiMsgResult();
|
|
LapiMsgResult lapiMsgResult = new LapiMsgResult();
|
|
lapiMsgResult.setPersonName(personInfo.getName());
|
|
lapiMsgResult.setPersonName(personInfo.getName());
|
|
lapiMsgResult.setSuccess(true);
|
|
lapiMsgResult.setSuccess(true);
|
|
@@ -144,7 +141,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
lapiMsgResults.add(lapiMsgResult);
|
|
lapiMsgResults.add(lapiMsgResult);
|
|
}
|
|
}
|
|
|
|
|
|
- }catch (Exception e){
|
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
|
log.error(e.getMessage());
|
|
log.error(e.getMessage());
|
|
LapiMsgResult lapiMsgResult = new LapiMsgResult();
|
|
LapiMsgResult lapiMsgResult = new LapiMsgResult();
|
|
@@ -163,65 +160,65 @@ public class LapiServiceImpl implements ILapiService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public String getFaceDbId(DeviceInfo deviceInfo, String companyName) throws Exception{
|
|
|
|
- if (StringUtils.isBlank(companyName)){
|
|
|
|
|
|
+ public String getFaceDbId(DeviceInfo deviceInfo, String companyName) throws Exception {
|
|
|
|
+ if (StringUtils.isBlank(companyName)) {
|
|
throw new Exception("公司名称为空");
|
|
throw new Exception("公司名称为空");
|
|
}
|
|
}
|
|
String faceDbId = "";
|
|
String faceDbId = "";
|
|
- JSONObject jsonObject = LApiUtil.GetRequest(deviceInfo.getIpAddress()+":" + deviceInfo.getPort()+LApiConstant.GETFACEDB);
|
|
|
|
|
|
+ JSONObject jsonObject = LApiUtil.GetRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.GETFACEDB);
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
List listData = response.getJSONArray("LibList");
|
|
List listData = response.getJSONArray("LibList");
|
|
- if (listData.size()<=0){
|
|
|
|
|
|
+ if (listData.size() <= 0) {
|
|
throw new Exception("设备没有配置人脸库");
|
|
throw new Exception("设备没有配置人脸库");
|
|
}
|
|
}
|
|
- for (int i =0;i<listData.size();i++){
|
|
|
|
|
|
+ for (int i = 0; i < listData.size(); i++) {
|
|
JSONObject jsonObject1 = (JSONObject) JSONArray.toJSON(listData.get(i));
|
|
JSONObject jsonObject1 = (JSONObject) JSONArray.toJSON(listData.get(i));
|
|
String name = jsonObject1.getString("Name");
|
|
String name = jsonObject1.getString("Name");
|
|
- if (StringUtils.isNotBlank(name) && companyName.equals(name)){
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(name) && companyName.equals(name)) {
|
|
faceDbId = jsonObject1.getString("ID");
|
|
faceDbId = jsonObject1.getString("ID");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//人员所属的公司库不存在,保存到默认库
|
|
//人员所属的公司库不存在,保存到默认库
|
|
- if (StringUtils.isBlank(faceDbId)){
|
|
|
|
|
|
+ if (StringUtils.isBlank(faceDbId)) {
|
|
faceDbId = deviceInfo.getDefaultFaceLibraryId();
|
|
faceDbId = deviceInfo.getDefaultFaceLibraryId();
|
|
}
|
|
}
|
|
return faceDbId;
|
|
return faceDbId;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public List<LapiMsgResult> deletePerson(Long id) throws Exception{
|
|
|
|
|
|
+ public List<LapiMsgResult> deletePerson(Long id) throws Exception {
|
|
|
|
|
|
PersonInfo personInfo = personInfoService.get(id);
|
|
PersonInfo personInfo = personInfoService.get(id);
|
|
- if (personInfo == null){
|
|
|
|
|
|
+ if (personInfo == null) {
|
|
throw new Exception("人员不存在");
|
|
throw new Exception("人员不存在");
|
|
}
|
|
}
|
|
List<PersonDeviceRelation> listRelation = personDeviceRelationService.findByPersonId(id);
|
|
List<PersonDeviceRelation> listRelation = personDeviceRelationService.findByPersonId(id);
|
|
- if (listRelation.size()<=0){
|
|
|
|
|
|
+ if (listRelation.size() <= 0) {
|
|
throw new Exception("人员未绑定设备");
|
|
throw new Exception("人员未绑定设备");
|
|
}
|
|
}
|
|
CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
|
|
CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
|
|
List<DeviceInfo> deviceList = new ArrayList<>();
|
|
List<DeviceInfo> deviceList = new ArrayList<>();
|
|
- for (PersonDeviceRelation personDeviceRelation:listRelation){
|
|
|
|
|
|
+ for (PersonDeviceRelation personDeviceRelation : listRelation) {
|
|
DeviceInfo deviceInfo = deviceInfoService.get(personDeviceRelation.getDeviceId());
|
|
DeviceInfo deviceInfo = deviceInfoService.get(personDeviceRelation.getDeviceId());
|
|
- if (deviceInfo!=null && !deviceInfo.getDelFlag()){
|
|
|
|
|
|
+ if (deviceInfo != null && !deviceInfo.getDelFlag()) {
|
|
deviceList.add(deviceInfo);
|
|
deviceList.add(deviceInfo);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (deviceList.size()<=0){
|
|
|
|
|
|
+ if (deviceList.size() <= 0) {
|
|
throw new Exception("人员与设备绑定错误");
|
|
throw new Exception("人员与设备绑定错误");
|
|
}
|
|
}
|
|
|
|
|
|
List<LapiMsgResult> lapiMsgResults = new ArrayList<>();
|
|
List<LapiMsgResult> lapiMsgResults = new ArrayList<>();
|
|
- for (DeviceInfo deviceInfo : deviceList){
|
|
|
|
|
|
+ for (DeviceInfo deviceInfo : deviceList) {
|
|
|
|
|
|
- try{
|
|
|
|
|
|
+ try {
|
|
//获取人员人脸库id
|
|
//获取人员人脸库id
|
|
- String faceDbId = getFaceDbId(deviceInfo,companyInfo.getName());
|
|
|
|
- JSONObject jsonObject = LApiUtil.DeletRequest(deviceInfo.getIpAddress()+":"+deviceInfo.getPort()+LApiConstant.DELETEPERSON+faceDbId+"/People/"+personInfo.getId()+"?LastChange="+new Date().getTime());
|
|
|
|
|
|
+ String faceDbId = getFaceDbId(deviceInfo, companyInfo.getName());
|
|
|
|
+ JSONObject jsonObject = LApiUtil.DeletRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.DELETEPERSON + faceDbId + "/People/" + personInfo.getId() + "?LastChange=" + new Date().getTime());
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
JSONObject response = LApiUtil.getResponse(dataJson);
|
|
- if (dataJson.getInteger("ResponseCode") ==0 && dataJson.getInteger("StatusCode") == 0){
|
|
|
|
|
|
+ if (dataJson.getInteger("ResponseCode") == 0 && dataJson.getInteger("StatusCode") == 0) {
|
|
LapiMsgResult lapiMsgResult = new LapiMsgResult();
|
|
LapiMsgResult lapiMsgResult = new LapiMsgResult();
|
|
lapiMsgResult.setPersonName(personInfo.getName());
|
|
lapiMsgResult.setPersonName(personInfo.getName());
|
|
lapiMsgResult.setSuccess(true);
|
|
lapiMsgResult.setSuccess(true);
|
|
@@ -229,7 +226,7 @@ public class LapiServiceImpl implements ILapiService {
|
|
lapiMsgResults.add(lapiMsgResult);
|
|
lapiMsgResults.add(lapiMsgResult);
|
|
}
|
|
}
|
|
|
|
|
|
- }catch (Exception e){
|
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
|
log.error(e.getMessage());
|
|
log.error(e.getMessage());
|
|
LapiMsgResult lapiMsgResult = new LapiMsgResult();
|
|
LapiMsgResult lapiMsgResult = new LapiMsgResult();
|
|
@@ -246,4 +243,205 @@ public class LapiServiceImpl implements ILapiService {
|
|
|
|
|
|
return lapiMsgResults;
|
|
return lapiMsgResults;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Boolean phoneOpenDoor(String deviceInfoId) throws Exception {
|
|
|
|
+ DeviceInfo deviceInfo = deviceInfoService.get(deviceInfoId);
|
|
|
|
+ if (deviceInfo == null) {
|
|
|
|
+ throw new Exception("设备不存在");
|
|
|
|
+ }
|
|
|
|
+ if (deviceInfo.getDelFlag()) {
|
|
|
|
+ throw new Exception("设备已删除");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ JSONObject jsonObject = LApiUtil.putRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.REMOTEOPENED);
|
|
|
|
+ JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
|
+ JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Boolean reBoot(String deviceInfoId) throws Exception {
|
|
|
|
+ DeviceInfo deviceInfo = deviceInfoService.get(deviceInfoId);
|
|
|
|
+ if (deviceInfo == null) {
|
|
|
|
+ throw new Exception("设备不存在");
|
|
|
|
+ }
|
|
|
|
+ if (deviceInfo.getDelFlag()) {
|
|
|
|
+ throw new Exception("设备已删除");
|
|
|
|
+ }
|
|
|
|
+ JSONObject jsonObject = LApiUtil.putRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.REBOOT);
|
|
|
|
+ JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
|
+ JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<LapiResult> addCompanyLib(String companyInfoId, String deviceInfoIds) throws Exception {
|
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(companyInfoId);
|
|
|
|
+ if (companyInfo == null) {
|
|
|
|
+ throw new Exception("公司不存在");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isBlank(deviceInfoIds)) {
|
|
|
|
+ throw new Exception("请选择设备");
|
|
|
|
+ }
|
|
|
|
+ List<String> idList = Arrays.asList(deviceInfoIds.split(","));
|
|
|
|
+ List<LapiResult> lapiResultList = new ArrayList<>();
|
|
|
|
+ for (String deviceInfoId : idList) {
|
|
|
|
+ DeviceInfo deviceInfo = deviceInfoService.get(deviceInfoId);
|
|
|
|
+ LapiResult lapiResult = new LapiResult();
|
|
|
|
+ try {
|
|
|
|
+ if (deviceInfo == null) {
|
|
|
|
+ throw new Exception("设备不存在");
|
|
|
|
+ }
|
|
|
|
+ String companyLibId = getFaceDbId(deviceInfo, companyInfo.getName());
|
|
|
|
+ if (StringUtils.isNotBlank(companyLibId) && !companyLibId.equals(deviceInfo.getDefaultFaceLibraryId())) {
|
|
|
|
+ throw new Exception("已有人脸库不可重复创建");
|
|
|
|
+ }
|
|
|
|
+ HashMap map = new HashMap();
|
|
|
|
+ map.put("BelongIndex", "");
|
|
|
|
+ map.put("LastChange", new Date().getTime());
|
|
|
|
+ map.put("MemberNum", 0);
|
|
|
|
+ map.put("Name", companyInfo.getName());
|
|
|
|
+ map.put("Type", 3);
|
|
|
|
+ JSONObject jsonObject = LApiUtil.PostRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.ADDLIBRARY, map);
|
|
|
|
+ JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
|
+ JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
|
+ lapiResult.setMsg("添加成功");
|
|
|
|
+ lapiResult.setSuccess(true);
|
|
|
|
+ HashMap dataMap = new HashMap<>();
|
|
|
|
+ dataMap.put("CompanyId", companyInfoId);
|
|
|
|
+ dataMap.put("CompanyName", companyInfo.getName());
|
|
|
|
+ dataMap.put("LibraryId", response.getString("ID"));
|
|
|
|
+ lapiResult.setData(dataMap);
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error(e.getMessage());
|
|
|
|
+ lapiResult.setMsg(e.getMessage());
|
|
|
|
+ lapiResult.setSuccess(false);
|
|
|
|
+ lapiResult.setData("");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ lapiResultList.add(lapiResult);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return lapiResultList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public LapiResult deleteCompanyLib(String deviceInfoId, String libraryId) throws Exception {
|
|
|
|
+ if (StringUtils.isBlank(deviceInfoId)) {
|
|
|
|
+ throw new Exception("设备id为空");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isBlank(libraryId)) {
|
|
|
|
+ throw new Exception("人脸库id为空");
|
|
|
|
+ }
|
|
|
|
+ DeviceInfo deviceInfo = deviceInfoService.get(deviceInfoId);
|
|
|
|
+ if (deviceInfo == null) {
|
|
|
|
+ throw new Exception("设备不存在");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ LapiResult lapiResult = new LapiResult();
|
|
|
|
+ try {
|
|
|
|
+ JSONObject jsonObject = LApiUtil.DeletRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.DELETELIBRARY + libraryId);
|
|
|
|
+ JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
|
+ JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
|
+ lapiResult.setSuccess(true);
|
|
|
|
+ lapiResult.setMsg("删除成功");
|
|
|
|
+ lapiResult.setData("");
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ lapiResult.setMsg(e.getMessage());
|
|
|
|
+ lapiResult.setSuccess(false);
|
|
|
|
+ lapiResult.setData("");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return lapiResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public LapiResult updateCompanyLib(String companyId, String deviceInfoId, String libraryId) throws Exception {
|
|
|
|
+ if (StringUtils.isBlank(companyId)) {
|
|
|
|
+ throw new Exception("公司id为空");
|
|
|
|
+ }
|
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(companyId);
|
|
|
|
+ if (companyInfo == null) {
|
|
|
|
+ throw new Exception("公司不存在");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isBlank(deviceInfoId)) {
|
|
|
|
+ throw new Exception("设备id为空");
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isBlank(libraryId)) {
|
|
|
|
+ throw new Exception("人脸库id为空");
|
|
|
|
+ }
|
|
|
|
+ DeviceInfo deviceInfo = deviceInfoService.get(deviceInfoId);
|
|
|
|
+ if (deviceInfo == null) {
|
|
|
|
+ throw new Exception("设备不存在");
|
|
|
|
+ }
|
|
|
|
+ HashMap map = new HashMap();
|
|
|
|
+ map.put("Num", 1);
|
|
|
|
+ List list = new ArrayList();
|
|
|
|
+ HashMap map1 = new HashMap();
|
|
|
|
+ map1.put("ID", libraryId);
|
|
|
|
+ map1.put("LastChange", new Date().getTime());
|
|
|
|
+ map1.put("Name", companyInfo.getName());
|
|
|
|
+ map1.put("Type", 3);
|
|
|
|
+ map1.put("BelongIndex", "");
|
|
|
|
+ list.add(map1);
|
|
|
|
+ map.put("LibList", list);
|
|
|
|
+ JSONObject jsonObject = LApiUtil.putRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.UPDATALIBRARY, map);
|
|
|
|
+ JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
|
+ JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
|
+
|
|
|
|
+ HashMap dataMap = new HashMap<>();
|
|
|
|
+ dataMap.put("deviceId", deviceInfo.getId());
|
|
|
|
+ dataMap.put("deviceName", deviceInfo.getAliasName());
|
|
|
|
+ LapiResult lapiResult = new LapiResult();
|
|
|
|
+ lapiResult.setSuccess(true);
|
|
|
|
+ lapiResult.setMsg("更新成功");
|
|
|
|
+ lapiResult.setData(dataMap);
|
|
|
|
+ return lapiResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<LapiResult> deleteDeviceAllCompanyLib(String deviceInfoId) throws Exception {
|
|
|
|
+ if (StringUtils.isBlank(deviceInfoId)) {
|
|
|
|
+ throw new Exception("设备id为空");
|
|
|
|
+ }
|
|
|
|
+ DeviceInfo deviceInfo = deviceInfoService.get(deviceInfoId);
|
|
|
|
+ if (deviceInfo == null) {
|
|
|
|
+ throw new Exception("设备不存在");
|
|
|
|
+ }
|
|
|
|
+ JSONObject jsonObject = LApiUtil.GetRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.UPDATALIBRARY);
|
|
|
|
+ JSONObject dataJson = jsonObject.getJSONObject("Response");
|
|
|
|
+ JSONObject response = LApiUtil.getResponse(dataJson);
|
|
|
|
+ List<LibraryVo> list = JSONObject.parseArray(response.getString("LibList"), LibraryVo.class);
|
|
|
|
+ if (list.size() <= 0) {
|
|
|
|
+ throw new Exception("设备没有配置人员库");
|
|
|
|
+ }
|
|
|
|
+ List<LapiResult> lapiResultList = new ArrayList<>();
|
|
|
|
+ for (LibraryVo libraryVo : list) {
|
|
|
|
+ LapiResult lapiResult = new LapiResult();
|
|
|
|
+ try {
|
|
|
|
+ JSONObject jsonObject1 = LApiUtil.DeletRequest(deviceInfo.getIpAddress() + ":" + deviceInfo.getPort() + LApiConstant.DELETELIBRARY + libraryVo.getID());
|
|
|
|
+ JSONObject dataJson1 = jsonObject1.getJSONObject("Response");
|
|
|
|
+ JSONObject response1 = LApiUtil.getResponse(dataJson1);
|
|
|
|
+ lapiResult.setSuccess(true);
|
|
|
|
+ lapiResult.setMsg("删除成功");
|
|
|
|
+ lapiResult.setData("");
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ lapiResult.setMsg(e.getMessage());
|
|
|
|
+ lapiResult.setSuccess(false);
|
|
|
|
+ lapiResult.setData("");
|
|
|
|
+ }
|
|
|
|
+ lapiResultList.add(lapiResult);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return lapiResultList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|