|
@@ -82,9 +82,15 @@ public class PersonInfoController {
|
|
|
MessageResult<PersonInfo> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
- personInfo.setName(personInfo.getName().replace(" ",""));
|
|
|
- personInfo.setPhone(personInfo.getPhone().replace(" ",""));
|
|
|
- personInfo.setIdCard(personInfo.getIdCard().replace(" ",""));
|
|
|
+ if(personInfo.getName()!= null) {
|
|
|
+ personInfo.setName(personInfo.getName().replace(" ", ""));
|
|
|
+ }
|
|
|
+ if(personInfo.getPhone()!= null) {
|
|
|
+ personInfo.setPhone(personInfo.getPhone().replace(" ", ""));
|
|
|
+ }
|
|
|
+ if(personInfo.getIdCard()!= null) {
|
|
|
+ personInfo.setIdCard(personInfo.getIdCard().replace(" ", ""));
|
|
|
+ }
|
|
|
|
|
|
Map<String, Object> searchParams = new HashMap<>();
|
|
|
searchParams.put("companyId", personInfo.getCompanyId());
|
|
@@ -264,8 +270,8 @@ public class PersonInfoController {
|
|
|
|
|
|
@ApiOperation(value="删除")
|
|
|
@PostMapping("delete/{id}")
|
|
|
- public MessageResult<Integer> delete(@PathVariable("id") Long id,@RequestAttribute String subject){
|
|
|
- MessageResult<Integer> msgResult = new MessageResult<>();
|
|
|
+ public MessageResult<Boolean> delete(@PathVariable("id") Long id,@RequestAttribute String subject){
|
|
|
+ MessageResult<Boolean> msgResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
|
PersonInfo personInfo = personInfoService.get(id);
|
|
@@ -277,11 +283,21 @@ public class PersonInfoController {
|
|
|
|
|
|
int affectCount = personInfoService.update(personInfo);
|
|
|
|
|
|
- deleteDevicePerson(id);
|
|
|
+ HSSFWorkbook workbook = new HSSFWorkbook();
|
|
|
+ HSSFSheet sheet = workbook.createSheet();
|
|
|
+ if(!deleteDevicePerson(id, sheet)){
|
|
|
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
|
+ workbook.write(output);
|
|
|
+ byte[] buffer = output.toByteArray();
|
|
|
+ ByteArrayInputStream input = new ByteArrayInputStream(buffer);
|
|
|
+ String downloadUrl = OSSUtil.upload(ossConfig,"import","error.xls",input);
|
|
|
+
|
|
|
+ msgResult.setData(false);
|
|
|
+ msgResult.setMessage(downloadUrl);
|
|
|
+ }
|
|
|
|
|
|
if (affectCount > 0) {
|
|
|
msgResult.setResult(true);
|
|
|
- msgResult.setData(affectCount);
|
|
|
} else {
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("删除失败");
|
|
@@ -299,8 +315,12 @@ public class PersonInfoController {
|
|
|
|
|
|
@ApiOperation(value="批量删除")
|
|
|
@PostMapping("batchDelete")
|
|
|
- public MessageResult<Integer> batchDelete(@RequestBody List<Long> idList,@RequestAttribute String subject){
|
|
|
- MessageResult<Integer> msgResult = new MessageResult<>();
|
|
|
+ public MessageResult<Boolean> batchDelete(@RequestBody List<Long> idList,@RequestAttribute String subject){
|
|
|
+ MessageResult<Boolean> msgResult = new MessageResult<>();
|
|
|
+ msgResult.setData(true);
|
|
|
+
|
|
|
+ HSSFWorkbook workbook = new HSSFWorkbook();
|
|
|
+ HSSFSheet sheet = workbook.createSheet();
|
|
|
|
|
|
try {
|
|
|
int affectCount = 0;
|
|
@@ -325,7 +345,9 @@ public class PersonInfoController {
|
|
|
}
|
|
|
cachedThreadPool.execute(new Runnable() {
|
|
|
public void run() {
|
|
|
- deleteDevicePerson(id);
|
|
|
+ if(!deleteDevicePerson(id, sheet)){
|
|
|
+ msgResult.setData(false);
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -333,7 +355,15 @@ public class PersonInfoController {
|
|
|
|
|
|
if (affectCount > 0) {
|
|
|
msgResult.setResult(true);
|
|
|
- msgResult.setData(affectCount);
|
|
|
+ if(!msgResult.getData()) {
|
|
|
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
|
+ workbook.write(output);
|
|
|
+ byte[] buffer = output.toByteArray();
|
|
|
+ ByteArrayInputStream input = new ByteArrayInputStream(buffer);
|
|
|
+ String downloadUrl = OSSUtil.upload(ossConfig,"import","error.xls",input);
|
|
|
+
|
|
|
+ msgResult.setMessage(downloadUrl);
|
|
|
+ }
|
|
|
} else {
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("删除失败");
|
|
@@ -463,8 +493,11 @@ public class PersonInfoController {
|
|
|
@ApiImplicitParams({
|
|
|
@ApiImplicitParam(name = "id",value = "人员编号", required = false, paramType = "form",dataType = "String")
|
|
|
})
|
|
|
- public MessageResult<PersonInfo> enabledFace(@RequestParam(value="id",defaultValue="") Long id,@RequestAttribute String subject){
|
|
|
- MessageResult<PersonInfo> msgResult = new MessageResult<>();
|
|
|
+ public MessageResult<Boolean> enabledFace(@RequestParam(value="id",defaultValue="") Long id,@RequestAttribute String subject){
|
|
|
+ HSSFWorkbook workbook = new HSSFWorkbook();
|
|
|
+ HSSFSheet sheet = workbook.createSheet();
|
|
|
+ MessageResult<Boolean> msgResult = new MessageResult<>();
|
|
|
+ msgResult.setData(true);
|
|
|
|
|
|
try {
|
|
|
PersonInfo personInfo = personInfoService.get(id);
|
|
@@ -474,7 +507,9 @@ public class PersonInfoController {
|
|
|
throw new Exception("人员信息不存在!");
|
|
|
}
|
|
|
|
|
|
- deleteDevicePerson(id);
|
|
|
+ if(!deleteDevicePerson(id, sheet)){
|
|
|
+ msgResult.setData(false);
|
|
|
+ }
|
|
|
|
|
|
personInfo.setFaceBound(false);
|
|
|
personInfo.setUpdateTime(new Date());
|
|
@@ -489,7 +524,15 @@ public class PersonInfoController {
|
|
|
|
|
|
if (affectCount > 0) {
|
|
|
msgResult.setResult(true);
|
|
|
- msgResult.setData(personInfo);
|
|
|
+ if(!msgResult.getData()){
|
|
|
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
|
+ workbook.write(output);
|
|
|
+ byte[] buffer = output.toByteArray();
|
|
|
+ ByteArrayInputStream input = new ByteArrayInputStream(buffer);
|
|
|
+ String downloadUrl = OSSUtil.upload(ossConfig,"import","error.xls",input);
|
|
|
+
|
|
|
+ msgResult.setMessage(downloadUrl);
|
|
|
+ }
|
|
|
}else{
|
|
|
msgResult.setResult(false);
|
|
|
msgResult.setMessage("数据库保存失败");
|
|
@@ -968,11 +1011,15 @@ public class PersonInfoController {
|
|
|
|
|
|
@ApiOperation(value="数据同步")
|
|
|
@PostMapping("dataSync")
|
|
|
- public MessageResult<String> dataSync(@RequestBody List<String> ids){
|
|
|
- MessageResult<String> msgResult = new MessageResult<>();
|
|
|
+ public MessageResult<Boolean> dataSync(@RequestBody List<String> ids){
|
|
|
+ MessageResult<Boolean> msgResult = new MessageResult<>();
|
|
|
+ msgResult.setData(true);
|
|
|
msgResult.setResult(true);
|
|
|
|
|
|
try {
|
|
|
+ HSSFWorkbook workbook = new HSSFWorkbook();
|
|
|
+ HSSFSheet sheet = workbook.createSheet();
|
|
|
+
|
|
|
for(String id : ids){
|
|
|
PersonInfo personInfo = personInfoService.get(Long.valueOf(id));
|
|
|
|
|
@@ -980,37 +1027,25 @@ public class PersonInfoController {
|
|
|
throw new Exception("人员信息不存在!");
|
|
|
}
|
|
|
|
|
|
- //todo 同步终端
|
|
|
- boolean success = true;
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
- List<LapiMsgResult> msgResultList = lapiService.addPerson(Long.valueOf(id));
|
|
|
- for(int i=0;i<msgResultList.size();i++) {
|
|
|
- LapiMsgResult lapiMsgResult = msgResultList.get(i);
|
|
|
-
|
|
|
- if (lapiMsgResult.isSuccess()){
|
|
|
-// sb.append("【" + personInfo.getName() + "】" + lapiMsgResult.getAliasName() + "绑定人脸信息成功!");
|
|
|
- }
|
|
|
- else{
|
|
|
- sb.append("【" + personInfo.getName() + "】" + lapiMsgResult.getAliasName() + "绑定人脸信息失败!" + lapiMsgResult.getMsg());
|
|
|
- msgResult.setResult(false);
|
|
|
- }
|
|
|
-
|
|
|
- if (i!=msgResultList.size()-1){
|
|
|
- sb.append(",");
|
|
|
- }
|
|
|
- else{
|
|
|
- sb.append("。");
|
|
|
- }
|
|
|
-
|
|
|
- success &= lapiMsgResult.isSuccess();
|
|
|
+ if(!addDevicePerson(Long.valueOf(id), sheet)){
|
|
|
+ msgResult.setData(false);
|
|
|
+ personInfo.setFaceBound(false);
|
|
|
+ }else {
|
|
|
+ personInfo.setFaceBound(true);
|
|
|
}
|
|
|
-
|
|
|
- personInfo.setFaceBound(success);
|
|
|
- personInfo.setFaceEnabled(success);
|
|
|
+ personInfo.setFaceEnabled(true);
|
|
|
personInfo.setUpdateTime(new Date());
|
|
|
personInfoService.update(personInfo);
|
|
|
+ }
|
|
|
|
|
|
- msgResult.setMessage(sb.toString());
|
|
|
+ if(!msgResult.getData()){
|
|
|
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
|
+ workbook.write(output);
|
|
|
+ byte[] buffer = output.toByteArray();
|
|
|
+ ByteArrayInputStream input = new ByteArrayInputStream(buffer);
|
|
|
+ String downloadUrl = OSSUtil.upload(ossConfig,"import","error.xls",input);
|
|
|
+
|
|
|
+ msgResult.setMessage(downloadUrl);
|
|
|
}
|
|
|
}
|
|
|
catch(Exception ex){
|
|
@@ -1024,80 +1059,68 @@ public class PersonInfoController {
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value="删除设备人员图片")
|
|
|
- private MessageResult deleteDevicePerson(Long personId){
|
|
|
- MessageResult msgResult = new MessageResult();
|
|
|
- boolean success = true;
|
|
|
+ private Boolean deleteDevicePerson(Long personId, HSSFSheet sheet){
|
|
|
+ boolean bl = true;
|
|
|
|
|
|
try {
|
|
|
PersonInfo personInfo = personInfoService.get(personId);
|
|
|
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
List<LapiMsgResult> msgResultList = lapiService.deletePerson(personId);
|
|
|
for (int i = 0; i < msgResultList.size(); i++) {
|
|
|
LapiMsgResult lapiMsgResult = msgResultList.get(i);
|
|
|
|
|
|
- if (lapiMsgResult.isSuccess()) {
|
|
|
- sb.append("【" + personInfo.getName() + "】" + lapiMsgResult.getAliasName() + "解绑人脸信息成功!");
|
|
|
- } else {
|
|
|
- sb.append("【" + personInfo.getName() + "】" + lapiMsgResult.getAliasName() + "解绑人脸信息失败!" + lapiMsgResult.getMsg());
|
|
|
+ if (!lapiMsgResult.isSuccess()) {
|
|
|
+ HSSFRow row = sheet.createRow(sheet.getLastRowNum() + 1);
|
|
|
+ HSSFCell cell1 = row.createCell(0);
|
|
|
+ cell1.setCellValue(personInfo.getName());
|
|
|
+ HSSFCell cell2 = row.createCell(1);
|
|
|
+ cell2.setCellValue(lapiMsgResult.getAliasName());
|
|
|
+ HSSFCell cell3 = row.createCell(2);
|
|
|
+ cell3.setCellValue("解绑人脸信息失败!");
|
|
|
+ HSSFCell cell4 = row.createCell(3);
|
|
|
+ cell4.setCellValue(lapiMsgResult.getMsg());
|
|
|
+
|
|
|
+ bl = false;
|
|
|
}
|
|
|
-
|
|
|
- if (i != msgResultList.size() - 1) {
|
|
|
- sb.append(",");
|
|
|
- } else {
|
|
|
- sb.append("。");
|
|
|
- }
|
|
|
-
|
|
|
- success &= lapiMsgResult.isSuccess();
|
|
|
-
|
|
|
- msgResult.setResult(true);
|
|
|
- msgResult.setMessage(sb.toString());
|
|
|
}
|
|
|
}catch(Exception ex) {
|
|
|
logger.error(ex.getMessage(), ex);
|
|
|
- msgResult.setResult(false);
|
|
|
- msgResult.setMessage(ex.getMessage());
|
|
|
+ bl = false;
|
|
|
}
|
|
|
|
|
|
- return msgResult;
|
|
|
+ return bl;
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value="添加设备人员图片")
|
|
|
- private MessageResult addDevicePerson(Long personId){
|
|
|
- MessageResult msgResult = new MessageResult();
|
|
|
- boolean success = true;
|
|
|
+ private Boolean addDevicePerson(Long personId, HSSFSheet sheet){
|
|
|
+ boolean bl = true;
|
|
|
|
|
|
try {
|
|
|
PersonInfo personInfo = personInfoService.get(personId);
|
|
|
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
List<LapiMsgResult> msgResultList = lapiService.addPerson(personId);
|
|
|
for (int i = 0; i < msgResultList.size(); i++) {
|
|
|
LapiMsgResult lapiMsgResult = msgResultList.get(i);
|
|
|
|
|
|
- if (lapiMsgResult.isSuccess()) {
|
|
|
- sb.append("【" + personInfo.getName() + "】" + lapiMsgResult.getAliasName() + "解绑人脸信息成功!");
|
|
|
- } else {
|
|
|
- sb.append("【" + personInfo.getName() + "】" + lapiMsgResult.getAliasName() + "解绑人脸信息失败!" + lapiMsgResult.getMsg());
|
|
|
- }
|
|
|
-
|
|
|
- if (i != msgResultList.size() - 1) {
|
|
|
- sb.append(",");
|
|
|
- } else {
|
|
|
- sb.append("。");
|
|
|
+ if (!lapiMsgResult.isSuccess()) {
|
|
|
+ HSSFRow row = sheet.createRow(sheet.getLastRowNum() + 1);
|
|
|
+ HSSFCell cell1 = row.createCell(0);
|
|
|
+ cell1.setCellValue(personInfo.getName());
|
|
|
+ HSSFCell cell2 = row.createCell(1);
|
|
|
+ cell2.setCellValue(lapiMsgResult.getAliasName());
|
|
|
+ HSSFCell cell3 = row.createCell(2);
|
|
|
+ cell3.setCellValue("绑定人脸信息失败!");
|
|
|
+ HSSFCell cell4 = row.createCell(3);
|
|
|
+ cell4.setCellValue(lapiMsgResult.getMsg());
|
|
|
+
|
|
|
+ bl = false;
|
|
|
}
|
|
|
-
|
|
|
- success &= lapiMsgResult.isSuccess();
|
|
|
-
|
|
|
- msgResult.setResult(true);
|
|
|
- msgResult.setMessage(sb.toString());
|
|
|
}
|
|
|
}catch(Exception ex) {
|
|
|
logger.error(ex.getMessage(), ex);
|
|
|
- msgResult.setResult(false);
|
|
|
- msgResult.setMessage(ex.getMessage());
|
|
|
+ bl = false;
|
|
|
}
|
|
|
|
|
|
- return msgResult;
|
|
|
+ return bl;
|
|
|
}
|
|
|
}
|