|
@@ -93,13 +93,17 @@ public class PersonDeviceRelationController {
|
|
|
|
|
|
if (affectCount > 0) {
|
|
|
//往设备库传输人脸信息
|
|
|
- List<LapiMsgResult> lapiResults = lapiService.addPersonForDeviceIds(personDeviceRelation.getPersonId(),personDeviceRelation.getDeviceId());
|
|
|
- for (int i = 0; i < lapiResults.size(); i++) {
|
|
|
- LapiMsgResult lapiMsgResult = lapiResults.get(i);
|
|
|
- if (lapiMsgResult.isSuccess()) {
|
|
|
- msgResult.setResult(true);
|
|
|
- }else{
|
|
|
- throw new Exception("添加失败:" + lapiMsgResult.getMsg());
|
|
|
+ PersonInfo personInfo = personInfoService.get(personDeviceRelation.getPersonId());
|
|
|
+ //如果人员照片不为空
|
|
|
+ if(StringUtils.isNotEmpty(personInfo.getFaceImageUrl())){
|
|
|
+ List<LapiMsgResult> lapiResults = lapiService.addPersonForDeviceIds(personDeviceRelation.getPersonId(),personDeviceRelation.getDeviceId());
|
|
|
+ for (int i = 0; i < lapiResults.size(); i++) {
|
|
|
+ LapiMsgResult lapiMsgResult = lapiResults.get(i);
|
|
|
+ if (lapiMsgResult.isSuccess()) {
|
|
|
+ msgResult.setResult(true);
|
|
|
+ }else{
|
|
|
+ throw new Exception("添加失败:" + lapiMsgResult.getMsg());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
msgResult.setResult(true);
|
|
@@ -158,37 +162,40 @@ public class PersonDeviceRelationController {
|
|
|
//往设备库传输人脸信息
|
|
|
//批量操作
|
|
|
int addCount = 0;
|
|
|
- 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{
|
|
|
-
|
|
|
- PersonInfo personInfo = personInfoService.get(personId);
|
|
|
- String personName = "";
|
|
|
- if(personInfo != null){
|
|
|
- personName = personInfo.getName();
|
|
|
+ //往设备库传输人脸信息
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+ 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());
|
|
|
+
|
|
|
+ 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());
|
|
|
-
|
|
|
- personDeviceRelationService.update(personDeviceRelation);
|
|
|
- addCount ++;
|
|
|
}
|
|
|
}
|
|
|
//
|
|
@@ -266,6 +273,13 @@ public class PersonDeviceRelationController {
|
|
|
affectCount += personDeviceRelationService.insert(item);
|
|
|
//往设备库传输人脸信息
|
|
|
//批量操作
|
|
|
+
|
|
|
+ PersonInfo personInfo = personInfoService.get(personId);
|
|
|
+ //如果人员照片为空
|
|
|
+ if(StringUtils.isEmpty(personInfo.getFaceImageUrl())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
List<LapiMsgResult> lapiResults = lapiService.addPersonForDeviceIds(personId,deviceId);
|
|
|
|
|
|
for (int i = 0; i < lapiResults.size(); i++) {
|
|
@@ -327,6 +341,63 @@ public class PersonDeviceRelationController {
|
|
|
return msgResult;
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value="多个人员与设备批量解除绑定")
|
|
|
+ @PostMapping("batchUnBindPerson")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "persons",value = "人员ID(多个人员)", required = true,paramType = "query"),
|
|
|
+ @ApiImplicitParam(name = "deviceId",value = "设备ID", required = true, paramType = "query")
|
|
|
+ })
|
|
|
+ public MessageResult<Integer> batchUnBindPerson(String persons,String deviceId,@RequestAttribute String subject){
|
|
|
+ MessageResult<Integer> msgResult = new MessageResult<>();
|
|
|
+ int affectCount = 0;
|
|
|
+
|
|
|
+ try {
|
|
|
+ if(StringUtil.isNotEmpty(persons)){
|
|
|
+
|
|
|
+ String[] personArray = persons.split(",");
|
|
|
+
|
|
|
+ for (String strPersonId:personArray) {
|
|
|
+
|
|
|
+ long personId = Long.parseLong(strPersonId);
|
|
|
+
|
|
|
+ PersonDeviceRelation item = personDeviceRelationService.findByDeviceIdAndPersonId(deviceId,personId);
|
|
|
+
|
|
|
+ if(item != null) {
|
|
|
+ item.setDelFlag(true);
|
|
|
+ item.setUpdateBy(subject);
|
|
|
+ item.setUpdateTime(new Date());
|
|
|
+ affectCount += personDeviceRelationService.update(item);
|
|
|
+ //删除设备上的信息
|
|
|
+ new Thread(()->{
|
|
|
+ try {
|
|
|
+ lapiService.deleteDevicePerson(personId,deviceId);
|
|
|
+ }
|
|
|
+ catch (Exception ex){
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+ }
|
|
|
+ }).start();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (affectCount > 0) {
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(affectCount);
|
|
|
+ } else {
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage("解绑失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch(Exception ex){
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation(value="获取人员和设备绑定信息")
|
|
|
@GetMapping("edit/{id}")
|
|
|
public MessageResult<PersonDeviceRelation> edit(@PathVariable("id") String id){
|
|
@@ -398,6 +469,16 @@ public class PersonDeviceRelationController {
|
|
|
int affectCount = personDeviceRelationService.update(personDeviceRelation);
|
|
|
|
|
|
if (affectCount > 0) {
|
|
|
+ //删除设备上的信息
|
|
|
+ new Thread(()->{
|
|
|
+ try {
|
|
|
+ lapiService.deleteDevicePerson(personDeviceRelation.getPersonId(),personDeviceRelation.getDeviceId());
|
|
|
+ }
|
|
|
+ catch (Exception ex){
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+ }
|
|
|
+ }).start();
|
|
|
+
|
|
|
msgResult.setResult(true);
|
|
|
msgResult.setData(affectCount);
|
|
|
} else {
|
|
@@ -435,6 +516,7 @@ public class PersonDeviceRelationController {
|
|
|
affectCount = personDeviceRelationService.update(personDeviceRelation);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
if (affectCount > 0) {
|
|
|
msgResult.setResult(true);
|
|
|
msgResult.setData(affectCount);
|
|
@@ -549,6 +631,17 @@ public class PersonDeviceRelationController {
|
|
|
affectCount += personDeviceRelationService.update(personDeviceRelation);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ //删除所有设备上的信息
|
|
|
+ new Thread(()->{
|
|
|
+ try {
|
|
|
+ lapiService.deletePerson(personId);
|
|
|
+ }
|
|
|
+ catch (Exception ex){
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+ }
|
|
|
+ }).start();
|
|
|
+
|
|
|
if (affectCount > 0) {
|
|
|
msgResult.setResult(true);
|
|
|
msgResult.setData(affectCount);
|