|
@@ -95,7 +95,7 @@ public class PersonDeviceRelationController {
|
|
personDeviceRelation.setDelFlag(false);
|
|
personDeviceRelation.setDelFlag(false);
|
|
personDeviceRelation.setCreateBy(subject);
|
|
personDeviceRelation.setCreateBy(subject);
|
|
personDeviceRelation.setCreateTime(new Date());
|
|
personDeviceRelation.setCreateTime(new Date());
|
|
- personDeviceRelation.setIsBound(true);//绑定设备默认true
|
|
|
|
|
|
+ personDeviceRelation.setIsBound(false);//绑定设备默认true
|
|
|
|
|
|
affectCount = personDeviceRelationService.insert(personDeviceRelation);
|
|
affectCount = personDeviceRelationService.insert(personDeviceRelation);
|
|
}
|
|
}
|
|
@@ -105,24 +105,24 @@ public class PersonDeviceRelationController {
|
|
//往设备库传输人脸信息
|
|
//往设备库传输人脸信息
|
|
PersonInfo personInfo = personInfoService.get(personDeviceRelation.getPersonId());
|
|
PersonInfo personInfo = personInfoService.get(personDeviceRelation.getPersonId());
|
|
//如果人员照片不为空
|
|
//如果人员照片不为空
|
|
- //if(StringUtils.isNotEmpty(personInfo.getFaceImageUrl())){
|
|
|
|
-
|
|
|
|
- DeviceInfo deviceInfo = deviceInfoService.get(personDeviceRelation.getDeviceId());
|
|
|
|
- if(!deviceInfo.getIsOnline()){
|
|
|
|
- throw new Exception("无法绑定,设备不在线!" );
|
|
|
|
- }
|
|
|
|
- List<LapiResult> lapiResults = lapiService.addPersonForDeviceIds(personDeviceRelation.getPersonId(),personDeviceRelation.getDeviceId());
|
|
|
|
- for (int i = 0; i < lapiResults.size(); i++) {
|
|
|
|
- LapiResult lapiMsgResult = lapiResults.get(i);
|
|
|
|
- if (lapiMsgResult.isSuccess()) {
|
|
|
|
- msgResult.setResult(true);
|
|
|
|
- }else{
|
|
|
|
- throw new Exception("添加失败:" + lapiMsgResult.getMsg());
|
|
|
|
|
|
+ if(StringUtils.isNotEmpty(personInfo.getFaceImageUrl())){
|
|
|
|
+ DeviceInfo deviceInfo = deviceInfoService.get(personDeviceRelation.getDeviceId());
|
|
|
|
+ if(!deviceInfo.getIsOnline()){
|
|
|
|
+ throw new Exception("无法绑定,设备不在线!" );
|
|
}
|
|
}
|
|
- }
|
|
|
|
- //}else{
|
|
|
|
|
|
+ List<LapiResult> lapiResults = lapiService.addPersonForDeviceIds(personDeviceRelation.getPersonId(),personDeviceRelation.getDeviceId());
|
|
|
|
+ for (int i = 0; i < lapiResults.size(); i++) {
|
|
|
|
+ LapiResult lapiMsgResult = lapiResults.get(i);
|
|
|
|
+ if (lapiMsgResult.isSuccess()) {
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
+ }else{
|
|
|
|
+ throw new Exception("添加失败:" + lapiMsgResult.getMsg());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
//throw new Exception("添加失败:人员没有上传照片" );
|
|
//throw new Exception("添加失败:人员没有上传照片" );
|
|
- //}
|
|
|
|
|
|
+ //没有照片 可以只进行数据绑定 不进行设备操作
|
|
|
|
+ }
|
|
msgResult.setResult(true);
|
|
msgResult.setResult(true);
|
|
msgResult.setData(personDeviceRelation);
|
|
msgResult.setData(personDeviceRelation);
|
|
} else {
|
|
} else {
|
|
@@ -169,7 +169,7 @@ public class PersonDeviceRelationController {
|
|
item.setDelFlag(false);
|
|
item.setDelFlag(false);
|
|
item.setCreateBy(subject);
|
|
item.setCreateBy(subject);
|
|
item.setCreateTime(new Date());
|
|
item.setCreateTime(new Date());
|
|
- item.setIsBound(true);//绑定设备默认true
|
|
|
|
|
|
+ item.setIsBound(false);//绑定设备默认false
|
|
|
|
|
|
affectCount += personDeviceRelationService.insert(item);
|
|
affectCount += personDeviceRelationService.insert(item);
|
|
}
|
|
}
|
|
@@ -183,43 +183,41 @@ public class PersonDeviceRelationController {
|
|
//往设备库传输人脸信息
|
|
//往设备库传输人脸信息
|
|
PersonInfo personInfo = personInfoService.get(personId);
|
|
PersonInfo personInfo = personInfoService.get(personId);
|
|
//如果人员照片不为空
|
|
//如果人员照片不为空
|
|
- //if(StringUtils.isNotEmpty(personInfo.getFaceImageUrl())) {
|
|
|
|
- List<LapiResult> lapiResults = lapiService.addPerson(personId);
|
|
|
|
- for (int i = 0; i < lapiResults.size(); i++) {
|
|
|
|
- LapiResult lapiResult = lapiResults.get(i);
|
|
|
|
- if (lapiResult.isSuccess()) {
|
|
|
|
- msgResult.setResult(true);
|
|
|
|
- } else {
|
|
|
|
- String personName = "";
|
|
|
|
- if (personInfo != null) {
|
|
|
|
- personName = personInfo.getName();
|
|
|
|
|
|
+ if(StringUtils.isNotEmpty(personInfo.getFaceImageUrl())) {
|
|
|
|
+ List<LapiResult> lapiResults = lapiService.addPerson(personId);
|
|
|
|
+ for (int i = 0; i < lapiResults.size(); i++) {
|
|
|
|
+ LapiResult lapiResult = lapiResults.get(i);
|
|
|
|
+ if (lapiResult.isSuccess()) {
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
+ } else {
|
|
|
|
+ String personName = "";
|
|
|
|
+ if (personInfo != null) {
|
|
|
|
+ personName = personInfo.getName();
|
|
|
|
+ }
|
|
|
|
+ Map resultMap = (Map) lapiResult.getData();
|
|
|
|
+ HSSFRow row = sheet.createRow(sheet.getLastRowNum() + 1);
|
|
|
|
+ HSSFCell cell1 = row.createCell(0);
|
|
|
|
+ cell1.setCellValue(personName);
|
|
|
|
+ HSSFCell cell2 = row.createCell(1);
|
|
|
|
+ cell2.setCellValue(resultMap.get("deviceAliasName").toString());
|
|
|
|
+ HSSFCell cell3 = row.createCell(2);
|
|
|
|
+ cell3.setCellValue("添加失败:");
|
|
|
|
+ HSSFCell cell4 = row.createCell(3);
|
|
|
|
+ cell4.setCellValue(lapiResult.getMsg());
|
|
|
|
+
|
|
|
|
+ //删除绑定关系
|
|
|
|
+ PersonDeviceRelation personDeviceRelation = personDeviceRelationService.findByDeviceIdAndPersonId(resultMap.get("deviceId").toString(), personId);
|
|
|
|
+ personDeviceRelation.setDelFlag(true);
|
|
|
|
+ personDeviceRelation.setUpdateBy(subject);
|
|
|
|
+ personDeviceRelation.setUpdateTime(new Date());
|
|
|
|
+ personDeviceRelation.setIsBound(false);
|
|
|
|
+
|
|
|
|
+ personDeviceRelationService.update(personDeviceRelation);
|
|
|
|
+ addCount++;
|
|
}
|
|
}
|
|
- Map resultMap = (Map) lapiResult.getData();
|
|
|
|
- HSSFRow row = sheet.createRow(sheet.getLastRowNum() + 1);
|
|
|
|
- HSSFCell cell1 = row.createCell(0);
|
|
|
|
- cell1.setCellValue(personName);
|
|
|
|
- HSSFCell cell2 = row.createCell(1);
|
|
|
|
- cell2.setCellValue(resultMap.get("deviceAliasName").toString());
|
|
|
|
- HSSFCell cell3 = row.createCell(2);
|
|
|
|
- cell3.setCellValue("添加失败:");
|
|
|
|
- HSSFCell cell4 = row.createCell(3);
|
|
|
|
- cell4.setCellValue(lapiResult.getMsg());
|
|
|
|
-
|
|
|
|
- //删除绑定关系
|
|
|
|
- PersonDeviceRelation personDeviceRelation = personDeviceRelationService.findByDeviceIdAndPersonId(resultMap.get("deviceId").toString(), personId);
|
|
|
|
- personDeviceRelation.setDelFlag(true);
|
|
|
|
- personDeviceRelation.setUpdateBy(subject);
|
|
|
|
- personDeviceRelation.setUpdateTime(new Date());
|
|
|
|
- personDeviceRelation.setIsBound(false);
|
|
|
|
-
|
|
|
|
- personDeviceRelationService.update(personDeviceRelation);
|
|
|
|
- addCount++;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- //}
|
|
|
|
//
|
|
//
|
|
-
|
|
|
|
-
|
|
|
|
if(addCount > 0){
|
|
if(addCount > 0){
|
|
//异常数量大于0,表示有部分数据同步失败
|
|
//异常数量大于0,表示有部分数据同步失败
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
@@ -288,15 +286,15 @@ public class PersonDeviceRelationController {
|
|
item.setDelFlag(false);
|
|
item.setDelFlag(false);
|
|
item.setCreateBy(subject);
|
|
item.setCreateBy(subject);
|
|
item.setCreateTime(new Date());
|
|
item.setCreateTime(new Date());
|
|
- item.setIsBound(true);//绑定设备默认true
|
|
|
|
|
|
+ item.setIsBound(false);//绑定设备默认false
|
|
|
|
|
|
affectCount += personDeviceRelationService.insert(item);
|
|
affectCount += personDeviceRelationService.insert(item);
|
|
//往设备库传输人脸信息
|
|
//往设备库传输人脸信息
|
|
//批量操作
|
|
//批量操作
|
|
|
|
|
|
-// PersonInfo personInfo = personInfoService.get(personId);
|
|
|
|
|
|
+ PersonInfo personInfo = personInfoService.get(personId);
|
|
// //如果人员照片为空
|
|
// //如果人员照片为空
|
|
-// if(StringUtils.isEmpty(personInfo.getFaceImageUrl())){
|
|
|
|
|
|
+ if(StringUtils.isEmpty(personInfo.getFaceImageUrl())){
|
|
// HSSFRow row = sheet.createRow(sheet.getLastRowNum() + 1);
|
|
// HSSFRow row = sheet.createRow(sheet.getLastRowNum() + 1);
|
|
// HSSFCell cell1 = row.createCell(0);
|
|
// HSSFCell cell1 = row.createCell(0);
|
|
// cell1.setCellValue(personInfo.getName());
|
|
// cell1.setCellValue(personInfo.getName());
|
|
@@ -312,8 +310,8 @@ public class PersonDeviceRelationController {
|
|
// item.setUpdateBy(subject);
|
|
// item.setUpdateBy(subject);
|
|
// item.setUpdateTime(new Date());
|
|
// item.setUpdateTime(new Date());
|
|
// personDeviceRelationService.update(item);
|
|
// personDeviceRelationService.update(item);
|
|
-// continue;
|
|
|
|
-// }
|
|
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
|
|
List<LapiResult> lapiResults = lapiService.addPersonForDeviceIds(personId,deviceId);
|
|
List<LapiResult> lapiResults = lapiService.addPersonForDeviceIds(personId,deviceId);
|
|
|
|
|