|
@@ -4,7 +4,9 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alipay.api.domain.Person;
|
|
|
import com.github.pagehelper.Page;
|
|
|
import com.jpsoft.smart.config.OSSConfig;
|
|
|
+import com.jpsoft.smart.modules.base.entity.PersonDeviceRelation;
|
|
|
import com.jpsoft.smart.modules.base.entity.PersonInfo;
|
|
|
+import com.jpsoft.smart.modules.base.service.PersonDeviceRelationService;
|
|
|
import com.jpsoft.smart.modules.base.service.PersonInfoService;
|
|
|
import com.jpsoft.smart.modules.common.dto.MessageResult;
|
|
|
import com.jpsoft.smart.modules.common.dto.Sort;
|
|
@@ -50,6 +52,9 @@ public class PersonInfoApiController {
|
|
|
@Autowired
|
|
|
private PersonInfoService personInfoService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private PersonDeviceRelationService personDeviceRelationService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ILapiService lapiService;
|
|
|
|
|
@@ -395,28 +400,49 @@ public class PersonInfoApiController {
|
|
|
throw new Exception("当前用户不是管理员!");
|
|
|
}
|
|
|
|
|
|
- PersonInfo personInfo = new PersonInfo();
|
|
|
- personInfo.setName(name);
|
|
|
- personInfo.setPhone(phone);
|
|
|
- personInfo.setFaceEnabled(true);
|
|
|
- personInfo.setCompanyId(admin.getCompanyId());
|
|
|
- personInfo.setDelFlag(false);
|
|
|
- personInfo.setCreateBy(String.valueOf(admin.getId()));
|
|
|
- personInfo.setCreateTime(new Date());
|
|
|
-
|
|
|
- int affectCount = personInfoService.insert(personInfo);
|
|
|
-
|
|
|
- //todo 关联设备
|
|
|
-
|
|
|
-
|
|
|
- if(affectCount>0) {
|
|
|
- //todo 加入到导入图片队列中
|
|
|
- rabbitTemplate.convertAndSend("importImageExchange", "importImage", personInfo.getId());
|
|
|
+ PersonInfo personInfo = personInfoService.findByNameAndPhone(name, phone);
|
|
|
+ if(personInfo == null) {
|
|
|
+ personInfo = new PersonInfo();
|
|
|
+ personInfo.setCompanyId(admin.getCompanyId());
|
|
|
+ personInfo.setName(name);
|
|
|
+ personInfo.setPhone(phone);
|
|
|
+ personInfo.setFaceEnabled(true);
|
|
|
+ personInfo.setFaceImageUrl(faceImageUrl);
|
|
|
+ personInfo.setPopedom("1");
|
|
|
+ personInfo.setDelFlag(false);
|
|
|
+ personInfo.setCreateBy(String.valueOf(admin.getId()));
|
|
|
+ personInfo.setCreateTime(new Date());
|
|
|
+
|
|
|
+ int affectCount = personInfoService.insert(personInfo);
|
|
|
+
|
|
|
+ personInfo = personInfoService.findByNameAndPhone(name, phone);
|
|
|
+
|
|
|
+ //todo 关联设备
|
|
|
+ String[] deviceIds = bindDevices.split(",");
|
|
|
+ for(String deviceId : deviceIds){
|
|
|
+ PersonDeviceRelation personDeviceRelation = new PersonDeviceRelation();
|
|
|
+ personDeviceRelation.setId(UUID.randomUUID().toString());
|
|
|
+ personDeviceRelation.setDeviceId(deviceId);
|
|
|
+ personDeviceRelation.setPersonId(personInfo.getId());
|
|
|
+ personDeviceRelation.setDelFlag(false);
|
|
|
+ personDeviceRelation.setCreateBy(subject);
|
|
|
+ personDeviceRelation.setCreateTime(new Date());
|
|
|
+ personDeviceRelationService.insert(personDeviceRelation);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(affectCount>0) {
|
|
|
+ //todo 加入到导入图片队列中
|
|
|
+ rabbitTemplate.convertAndSend("importImageExchange", "importImage", personInfo.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ messageResult.setData(personInfo);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage("人员已存在。");
|
|
|
}
|
|
|
-
|
|
|
- messageResult.setData(personInfo);
|
|
|
- messageResult.setResult(true);
|
|
|
- messageResult.setCode(200);
|
|
|
} catch (Exception e) {
|
|
|
logger.error(e.getMessage(),e);
|
|
|
messageResult.setResult(false);
|