优化新增/修改人员下发宇泛设备
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package com.dcsoft.system.controller;
|
||||
|
||||
import com.dcsoft.common.core.web.controller.BaseController;
|
||||
import com.dcsoft.common.core.web.page.TableDataInfo;
|
||||
import com.dcsoft.system.domain.SysEqDownRecord;
|
||||
import com.dcsoft.system.service.ISysEqDownRecordService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/sysEqDownRecord")
|
||||
@Slf4j
|
||||
public class SysEqDownRecordController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ISysEqDownRecordService sysEqDownRecordService;
|
||||
|
||||
/**
|
||||
* 分页查询设备下机记录列表
|
||||
*/
|
||||
@RequestMapping("/pageList")
|
||||
public TableDataInfo pageList(SysEqDownRecord sysEqDownRecord) {
|
||||
List<SysEqDownRecord> list = sysEqDownRecordService.pageList(sysEqDownRecord);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -154,153 +154,42 @@ public class SysPeopleController extends BaseController
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody SysPeople sysPeople) throws ExecutionException, InterruptedException {
|
||||
SysPeople people = sysPeopleService.selectSysPeopleByGh(sysPeople.getGh());
|
||||
if(people != null) {
|
||||
if (people != null) {
|
||||
return error("该工号已存在");
|
||||
}
|
||||
if(StringUtils.isNotEmpty(sysPeople.getDoorNo())) {
|
||||
|
||||
if (StringUtils.isNotEmpty(sysPeople.getDoorNo())) {
|
||||
SysPeople doorNo = sysPeopleService.selectSysPeopleByDoorNo(sysPeople.getDoorNo());
|
||||
if(doorNo != null) {
|
||||
if (doorNo != null) {
|
||||
return error("该门禁号已存在");
|
||||
}
|
||||
}
|
||||
|
||||
//判断设备是否上云
|
||||
String cloud = configService.selectConfigByKey("sys.equipment.cloud");
|
||||
int i=0;
|
||||
if("true".equals(cloud)){
|
||||
String data=sysApiService.admitCreate(sysPeople);
|
||||
JSONObject json= JSONObject.parseObject(data);
|
||||
if("1".equals(json.get("result")+"")){
|
||||
JSONObject obj= (JSONObject) json.get("data");
|
||||
String admitGuid=obj.get("admitGuid")+"";
|
||||
sysPeople.setGuid(admitGuid);
|
||||
//人像注册,如果注册失败将人像置空
|
||||
String datas=sysApiService.faceRegister(sysPeople);
|
||||
JSONObject jsons= JSONObject.parseObject(datas);
|
||||
if("1".equals(jsons.get("result")+"")){
|
||||
JSONObject objs= (JSONObject) jsons.get("data");
|
||||
String faceGuid=objs.get("faceGuid")+"";
|
||||
sysPeople.setFaceGuid(faceGuid);
|
||||
if (StringUtils.isNotEmpty(sysPeople.getAvatar())) {
|
||||
sysPeople.setFaceGuid(IdUtils.simpleUUID());
|
||||
}
|
||||
}else{
|
||||
return error(json.get("msg")+"");
|
||||
}
|
||||
i=sysPeopleService.insertSysPeople(sysPeople);
|
||||
}else{
|
||||
//注册设备进行注册
|
||||
if(StringUtils.isNotEmpty(sysPeople.getAvatar())) {//是否上传头像,检测照片是否合格
|
||||
SysEquipment equipment=new SysEquipment();
|
||||
equipment.setIsCj("1");
|
||||
equipment.setFlag("0");
|
||||
List<SysEquipment> list=equipmentService.selectSysEquipmentList(equipment);
|
||||
if(list.size()>0){
|
||||
//人员是否注册
|
||||
String ip=list.get(0).getIp();
|
||||
String pass=list.get(0).getPassword();
|
||||
if(StringUtils.isEmpty(sysPeople.getGuid())){
|
||||
Person person=new Person();
|
||||
person.setName(sysPeople.getName());
|
||||
person.setiDNumber(sysPeople.getIdcard());
|
||||
person.setPhone(sysPeople.getPhone());
|
||||
String data=sdkService.personCreate(person,ip,pass);
|
||||
JSONObject json= JSONObject.parseObject(data);
|
||||
if("1".equals(json.get("result")+"")) {
|
||||
JSONObject obj= (JSONObject) json.get("data");
|
||||
String admitGuid=obj.get("id")+"";
|
||||
sysPeople.setGuid(admitGuid);
|
||||
}else{
|
||||
return error(json.get("msg")+"");
|
||||
}
|
||||
}else{//更新人员信息
|
||||
sdkService.personDelete(sysPeople.getGuid(),ip,pass);
|
||||
Person person=new Person();
|
||||
person.setId(sysPeople.getGuid());
|
||||
person.setName(sysPeople.getName());
|
||||
person.setiDNumber(sysPeople.getIdcard());
|
||||
person.setPhone(sysPeople.getPhone());
|
||||
String data=sdkService.personCreate(person,ip,pass);
|
||||
JSONObject json= JSONObject.parseObject(data);
|
||||
if("1".equals(json.get("result")+"")) {
|
||||
}else{
|
||||
return error(json.get("msg")+"");
|
||||
}
|
||||
}
|
||||
//人像是否注册
|
||||
String datas = sdkService.imageCreateUrl(sysPeople.getGuid(), sysPeople.getAvatar(), ip, pass);
|
||||
JSONObject jsons = JSONObject.parseObject(datas);
|
||||
if ("1".equals(jsons.get("result")+"")) {
|
||||
if(jsons.get("data")!=null){
|
||||
String faceGuid = jsons.get("data")+"";
|
||||
sysPeople.setFaceGuid(faceGuid);
|
||||
}
|
||||
}else{
|
||||
return error(jsons.get("msg")+"");
|
||||
}
|
||||
//照片检测后删除注册设备人员
|
||||
sdkService.personDelete(sysPeople.getGuid(),ip,pass);
|
||||
}else{
|
||||
Long userId=SecurityUtils.getUserId();
|
||||
SysUser user=userService.selectUserById(userId);
|
||||
if(user.getEquipmentId()!=null){
|
||||
SysEquipment equipments = equipmentService.selectSysEquipmentById(user.getEquipmentId());
|
||||
String ip = equipments.getIp();
|
||||
String pass = equipments.getPassword();
|
||||
String flag = equipments.getFlag();
|
||||
if("0".equals(flag)){
|
||||
Person person=new Person();
|
||||
person.setName(sysPeople.getName());
|
||||
person.setiDNumber(sysPeople.getIdcard());
|
||||
person.setPhone(sysPeople.getPhone());
|
||||
String data=sdkService.personCreate(person,ip,pass);
|
||||
JSONObject json= JSONObject.parseObject(data);
|
||||
if("1".equals(json.get("result")+"")) {
|
||||
JSONObject obj= (JSONObject) json.get("data");
|
||||
String admitGuid=obj.get("id")+"";
|
||||
sysPeople.setGuid(admitGuid);
|
||||
}else{
|
||||
return error(json.get("msg")+"");
|
||||
}
|
||||
String datas = sdkService.imageCreateUrl(sysPeople.getGuid(), sysPeople.getAvatar(), ip, pass);
|
||||
JSONObject jsons = JSONObject.parseObject(datas);
|
||||
if ("1".equals(jsons.get("result")+"")) {
|
||||
if(jsons.get("data")!=null){
|
||||
String faceGuid = jsons.get("data")+"";
|
||||
sysPeople.setFaceGuid(faceGuid);
|
||||
}
|
||||
}else{
|
||||
return error(jsons.get("msg")+"");
|
||||
}
|
||||
//照片检测后删除注册设备人员
|
||||
sdkService.personDelete(sysPeople.getGuid(),ip,pass);
|
||||
}else {
|
||||
return error("默认设备设备已离线");
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
sysPeople.setGuid(IdUtils.simpleUUID());
|
||||
}
|
||||
|
||||
//下发设备
|
||||
if(sysPeople.getBranchId()!=null){
|
||||
SysBranch branch=sysBranchService.selectSysBranchById(sysPeople.getBranchId());
|
||||
if (branch.getRuleId()!= null) {
|
||||
if (StringUtils.isNotEmpty(sysPeople.getBranchId())) {
|
||||
SysBranch branch = sysBranchService.selectSysBranchById(sysPeople.getBranchId());
|
||||
if (null != branch.getRuleId()) {
|
||||
//添加人员授权信息
|
||||
SysRule rule=sysRuleService.selectSysRuleById(branch.getRuleId());
|
||||
String data=sdkService.authDeviceNew(rule,sysPeople);
|
||||
if("".equals(data)){
|
||||
return AjaxResult.error("该规则未绑定设备!");
|
||||
SysRule rule = sysRuleService.selectSysRuleById(branch.getRuleId());
|
||||
int i = sdkService.authDeviceAddUpdate(rule, sysPeople, 0);
|
||||
if (i > 0) {
|
||||
return AjaxResult.error(i + "个设备下发失败!");
|
||||
}
|
||||
sysPeople.setDown(1L);
|
||||
}
|
||||
}
|
||||
|
||||
//携物出门审核人
|
||||
if (CollUtil.isNotEmpty(sysPeople.getCarryStuffExamineList())) {
|
||||
sysPeople.setCarryStuffExamine(String.join(",", sysPeople.getCarryStuffExamineList()));
|
||||
}
|
||||
i=sysPeopleService.insertSysPeople(sysPeople);
|
||||
|
||||
}
|
||||
int i = sysPeopleService.insertSysPeople(sysPeople);
|
||||
return toAjax(i);
|
||||
}
|
||||
|
||||
@@ -311,172 +200,53 @@ public class SysPeopleController extends BaseController
|
||||
@RequiresPermissions("system:sysPeople:edit")
|
||||
@Log(title = "人员管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody SysPeople sysPeople)
|
||||
{
|
||||
//判断设备是否上云
|
||||
String cloud = configService.selectConfigByKey("sys.equipment.cloud");
|
||||
if("true".equals(cloud)) {
|
||||
if (StringUtils.isEmpty(sysPeople.getGuid())) {
|
||||
String data = sysApiService.admitUpdate(sysPeople);
|
||||
JSONObject json = JSONObject.parseObject(data);
|
||||
if ("1".equals(json.get("result") + "")) {
|
||||
//人像注册,如果注册失败将人像置空
|
||||
if (StringUtils.isEmpty(sysPeople.getFaceGuid())) {
|
||||
String datas = sysApiService.faceRegister(sysPeople);
|
||||
JSONObject jsons = JSONObject.parseObject(datas);
|
||||
if ("1".equals(jsons.get("result") + "")) {
|
||||
JSONObject objs = (JSONObject) jsons.get("data");
|
||||
String faceGuid = objs.get("faceGuid") + "";
|
||||
sysPeople.setFaceGuid(faceGuid);
|
||||
public AjaxResult edit(@RequestBody SysPeople sysPeople) {
|
||||
|
||||
|
||||
SysPeople people = sysPeopleService.selectSysPeopleByGh(sysPeople.getGh());
|
||||
if (people != null && !people.getId().equals(sysPeople.getId())) {
|
||||
return error("该工号已存在");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return error(json.get("msg") + "");
|
||||
}
|
||||
}else {
|
||||
//人像注册,如果注册失败将人像置空
|
||||
if (StringUtils.isEmpty(sysPeople.getFaceGuid())) {
|
||||
String datas = sysApiService.faceRegister(sysPeople);
|
||||
JSONObject jsons = JSONObject.parseObject(datas);
|
||||
if ("1".equals(jsons.get("result") + "")) {
|
||||
JSONObject objs = (JSONObject) jsons.get("data");
|
||||
String faceGuid = objs.get("faceGuid") + "";
|
||||
sysPeople.setFaceGuid(faceGuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
//注册设备进行注册
|
||||
if(StringUtils.isNotEmpty(sysPeople.getAvatar())) {//是否上传头像,检测照片是否合格
|
||||
SysEquipment equipment=new SysEquipment();
|
||||
equipment.setIsCj("1");
|
||||
equipment.setFlag("0");
|
||||
List<SysEquipment> list=equipmentService.selectSysEquipmentList(equipment);
|
||||
if(list.size()>0){
|
||||
//人员是否注册
|
||||
String ip=list.get(0).getIp();
|
||||
String pass=list.get(0).getPassword();
|
||||
if(StringUtils.isEmpty(sysPeople.getGuid())){
|
||||
Person person=new Person();
|
||||
person.setName(sysPeople.getName());
|
||||
person.setiDNumber(sysPeople.getIdcard());
|
||||
person.setPhone(sysPeople.getPhone());
|
||||
String data=sdkService.personCreate(person,ip,pass);
|
||||
JSONObject json= JSONObject.parseObject(data);
|
||||
log.info("人员修改-personCreate-result:{}", json.toJSONString());
|
||||
if("1".equals(json.get("result")+"")) {
|
||||
JSONObject obj= (JSONObject) json.get("data");
|
||||
String admitGuid=obj.get("id")+"";
|
||||
sysPeople.setGuid(admitGuid);
|
||||
}else{
|
||||
return error(json.get("msg")+"");
|
||||
}
|
||||
}else{//更新人员信息
|
||||
sdkService.personDelete(sysPeople.getGuid(),ip,pass);
|
||||
Person person=new Person();
|
||||
person.setId(sysPeople.getGuid());
|
||||
person.setName(sysPeople.getName());
|
||||
person.setiDNumber(sysPeople.getIdcard());
|
||||
person.setPhone(sysPeople.getPhone());
|
||||
String data=sdkService.personCreate(person,ip,pass);
|
||||
JSONObject json= JSONObject.parseObject(data);
|
||||
log.info("人员修改-personCreate2-result:{}", json.toJSONString());
|
||||
if("1".equals(json.get("result")+"")) {
|
||||
}else{
|
||||
return error(json.get("msg")+"");
|
||||
|
||||
if (StringUtils.isNotEmpty(sysPeople.getDoorNo())) {
|
||||
SysPeople doorNo = sysPeopleService.selectSysPeopleByDoorNo(sysPeople.getDoorNo());
|
||||
if (doorNo != null && !doorNo.getId().equals(sysPeople.getId())) {
|
||||
return error("该门禁号已存在");
|
||||
}
|
||||
}
|
||||
|
||||
//人像是否注册
|
||||
String datas = sdkService.imageCreateUrl(sysPeople.getGuid(), sysPeople.getAvatar(), ip, pass);
|
||||
JSONObject jsons = JSONObject.parseObject(datas);
|
||||
log.info("人员修改-imageCreateUrl-result:{}", jsons.toJSONString());
|
||||
if ("1".equals(jsons.get("result")+"")) {
|
||||
if(jsons.get("data")!=null){
|
||||
String faceGuid = jsons.get("data")+"";
|
||||
sysPeople.setFaceGuid(faceGuid);
|
||||
}
|
||||
}else{
|
||||
return error(jsons.get("msg")+"");
|
||||
}
|
||||
//照片检测后删除注册设备人员
|
||||
sdkService.personDelete(sysPeople.getGuid(),ip,pass);
|
||||
}else{
|
||||
Long userId=SecurityUtils.getUserId();
|
||||
SysUser user=userService.selectUserById(userId);
|
||||
if(user.getEquipmentId()!=null){
|
||||
SysEquipment equipments = equipmentService.selectSysEquipmentById(user.getEquipmentId());
|
||||
String ip = equipments.getIp();
|
||||
String pass = equipments.getPassword();
|
||||
String flag = equipments.getFlag();
|
||||
if("0".equals(flag)){
|
||||
if(StringUtils.isEmpty(sysPeople.getGuid())){
|
||||
Person person=new Person();
|
||||
person.setName(sysPeople.getName());
|
||||
person.setiDNumber(sysPeople.getIdcard());
|
||||
person.setPhone(sysPeople.getPhone());
|
||||
String data=sdkService.personCreate(person,ip,pass);
|
||||
JSONObject json= JSONObject.parseObject(data);
|
||||
if("1".equals(json.get("result")+"")) {
|
||||
JSONObject obj= (JSONObject) json.get("data");
|
||||
String admitGuid=obj.get("id")+"";
|
||||
sysPeople.setGuid(admitGuid);
|
||||
}else{
|
||||
return error(json.get("msg")+"");
|
||||
}
|
||||
if(StringUtils.isNotEmpty(sysPeople.getAvatar())){
|
||||
String datas = sdkService.imageCreateUrl(sysPeople.getGuid(), sysPeople.getAvatar(), ip, pass);
|
||||
JSONObject jsons = JSONObject.parseObject(datas);
|
||||
if ("true".equals(jsons.get("success") + "")) {
|
||||
if(jsons.get("data")!=null){
|
||||
String faceGuid = jsons.get("data")+"";
|
||||
sysPeople.setFaceGuid(faceGuid);
|
||||
}
|
||||
}else{
|
||||
return error(jsons.get("msg")+"");
|
||||
}
|
||||
}
|
||||
//照片检测后删除注册设备人员
|
||||
sdkService.personDelete(sysPeople.getGuid(),ip,pass);
|
||||
}else{
|
||||
if(StringUtils.isEmpty(sysPeople.getFaceGuid())){
|
||||
String datas = sdkService.imageCreateUrl(sysPeople.getGuid(), sysPeople.getAvatar(), ip, pass);
|
||||
JSONObject jsons = JSONObject.parseObject(datas);
|
||||
logger.info("进入无jsons==============="+jsons);
|
||||
if ("true".equals(jsons.get("success") + "")) {
|
||||
if(jsons.get("data")!=null){
|
||||
String faceGuid = jsons.get("data")+"";
|
||||
logger.info("进入无faceguid==============="+faceGuid);
|
||||
sysPeople.setFaceGuid(faceGuid);
|
||||
}
|
||||
}
|
||||
//照片检测后删除注册设备人员
|
||||
sdkService.personDelete(sysPeople.getGuid(),ip,pass);
|
||||
}
|
||||
SysPeople peopleById = sysPeopleService.selectSysPeopleById(sysPeople.getId());
|
||||
|
||||
//姓名、身份证号、头像、卡号、手机号变更下发设备
|
||||
boolean isDown = false;
|
||||
if (!StrUtil.equals(peopleById.getName(), sysPeople.getName()) ||
|
||||
!StrUtil.equals(peopleById.getIdcard(), sysPeople.getIdcard()) ||
|
||||
!StrUtil.equals(peopleById.getAvatar(), sysPeople.getAvatar()) ||
|
||||
!StrUtil.equals(peopleById.getDoorNo(), sysPeople.getDoorNo()) ||
|
||||
!StrUtil.equals(peopleById.getPhone(), sysPeople.getPhone())) {
|
||||
isDown = true;
|
||||
}
|
||||
|
||||
}else {
|
||||
return error("默认设备设备已离线");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotEmpty(sysPeople.getAvatar())) {
|
||||
sysPeople.setFaceGuid(peopleById.getFaceGuid());
|
||||
}
|
||||
sysPeople.setGuid(peopleById.getGuid());
|
||||
|
||||
//下发设备
|
||||
if (sysPeople.getBranchId() != null) {
|
||||
if (StringUtils.isNotEmpty(sysPeople.getBranchId()) && isDown) {
|
||||
SysBranch branch = sysBranchService.selectSysBranchById(sysPeople.getBranchId());
|
||||
if (branch.getRuleId() != null) {
|
||||
if (null != branch.getRuleId()) {
|
||||
//添加人员授权信息
|
||||
SysRule rule = sysRuleService.selectSysRuleById(branch.getRuleId());
|
||||
String data = sdkService.authDeviceNew(rule, sysPeople);
|
||||
log.info("人员修改-authDeviceNew-result:{}", data);
|
||||
int i = sdkService.authDeviceAddUpdate(rule, sysPeople, 1);
|
||||
if (i > 0) {
|
||||
return AjaxResult.error(i + "个设备下发失败!");
|
||||
}
|
||||
sysPeople.setDown(1L);
|
||||
if ("".equals(data)) {
|
||||
return AjaxResult.error("该规则未绑定设备!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (CollUtil.isNotEmpty(sysPeople.getCarryStuffExamineList())) {
|
||||
sysPeople.setCarryStuffExamine(String.join(",", sysPeople.getCarryStuffExamineList()));
|
||||
}
|
||||
@@ -484,122 +254,31 @@ public class SysPeopleController extends BaseController
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Log(title = "手机端人员管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/update")
|
||||
public AjaxResult update(@RequestBody SysPeople sysPeople)
|
||||
{
|
||||
//判断设备是否上云
|
||||
String cloud = configService.selectConfigByKey("sys.equipment.cloud");
|
||||
if("true".equals(cloud)) {
|
||||
if (StringUtils.isEmpty(sysPeople.getGuid())) {
|
||||
String data = sysApiService.admitUpdate(sysPeople);
|
||||
JSONObject json = JSONObject.parseObject(data);
|
||||
if ("1".equals(json.get("result") + "")) {
|
||||
//人像注册,如果注册失败将人像置空
|
||||
if (StringUtils.isEmpty(sysPeople.getFaceGuid())) {
|
||||
String datas = sysApiService.faceRegister(sysPeople);
|
||||
JSONObject jsons = JSONObject.parseObject(datas);
|
||||
if ("1".equals(jsons.get("result") + "")) {
|
||||
JSONObject objs = (JSONObject) jsons.get("data");
|
||||
String faceGuid = objs.get("faceGuid") + "";
|
||||
sysPeople.setFaceGuid(faceGuid);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return error(json.get("msg") + "");
|
||||
}
|
||||
}else {
|
||||
//人像注册,如果注册失败将人像置空
|
||||
if (StringUtils.isEmpty(sysPeople.getFaceGuid())) {
|
||||
String datas = sysApiService.faceRegister(sysPeople);
|
||||
JSONObject jsons = JSONObject.parseObject(datas);
|
||||
if ("true".equals(jsons.get("success") + "")) {
|
||||
JSONObject objs = (JSONObject) jsons.get("data");
|
||||
String faceGuid = objs.get("faceGuid") + "";
|
||||
sysPeople.setFaceGuid(faceGuid);
|
||||
}else{
|
||||
error(jsons.get("msg")+"");
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
//注册设备进行注册
|
||||
if(StringUtils.isNotEmpty(sysPeople.getAvatar())) {//是否上传头像,检测照片是否合格
|
||||
SysEquipment equipment=new SysEquipment();
|
||||
equipment.setIsCj("1");
|
||||
equipment.setFlag("0");
|
||||
List<SysEquipment> list=equipmentService.selectSysEquipmentList(equipment);
|
||||
if(list.size()>0){
|
||||
//人员是否注册
|
||||
String ip=list.get(0).getIp();
|
||||
String pass=list.get(0).getPassword();
|
||||
if(StringUtils.isEmpty(sysPeople.getGuid())){
|
||||
Person person=new Person();
|
||||
person.setName(sysPeople.getName());
|
||||
person.setiDNumber(sysPeople.getIdcard());
|
||||
person.setPhone(sysPeople.getPhone());
|
||||
String data=sdkService.personCreate(person,ip,pass);
|
||||
JSONObject json= JSONObject.parseObject(data);
|
||||
if("1".equals(json.get("result")+"")) {
|
||||
JSONObject obj= (JSONObject) json.get("data");
|
||||
String admitGuid=obj.get("id")+"";
|
||||
sysPeople.setGuid(admitGuid);
|
||||
}else{
|
||||
return error(json.get("msg")+"");
|
||||
}
|
||||
}else{//更新人员信息
|
||||
sdkService.personDelete(sysPeople.getGuid(),ip,pass);
|
||||
Person person=new Person();
|
||||
person.setId(sysPeople.getGuid());
|
||||
person.setName(sysPeople.getName());
|
||||
person.setiDNumber(sysPeople.getIdcard());
|
||||
person.setPhone(sysPeople.getPhone());
|
||||
String data=sdkService.personCreate(person,ip,pass);
|
||||
JSONObject json= JSONObject.parseObject(data);
|
||||
if("1".equals(json.get("result")+"")) {
|
||||
}else{
|
||||
return error(json.get("msg")+"");
|
||||
}
|
||||
}
|
||||
public AjaxResult update(@RequestBody SysPeople sysPeople) {
|
||||
|
||||
//查看是否有底图,有底图就注册
|
||||
SysPeople sysPeoples=sysPeopleService.selectSysPeopleById(sysPeople.getId());
|
||||
if(StringUtils.isNotEmpty(sysPeoples.getAvatar())){
|
||||
sdkService.imageCreateUrl(sysPeople.getGuid(), sysPeoples.getAvatar(), ip, pass);
|
||||
}
|
||||
SysPeople peopleById = sysPeopleService.selectSysPeopleById(sysPeople.getId());
|
||||
|
||||
//人像是否注册
|
||||
String datas = sdkService.imageCreateUrl(sysPeople.getGuid(), sysPeople.getAvatar(), ip, pass);
|
||||
JSONObject jsons = JSONObject.parseObject(datas);
|
||||
if ("true".equals(jsons.get("success")+"")) {
|
||||
if(jsons.get("data")!=null){
|
||||
String faceGuid = jsons.get("data")+"";
|
||||
sysPeople.setFaceGuid(faceGuid);
|
||||
//照片检测后删除注册设备人员
|
||||
sdkService.personDelete(sysPeople.getGuid(),ip,pass);
|
||||
}
|
||||
}else{
|
||||
//照片检测后删除注册设备人员
|
||||
sdkService.personDelete(sysPeople.getGuid(),ip,pass);
|
||||
return error(jsons.get("msg")+"");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotEmpty(sysPeople.getAvatar())) {
|
||||
sysPeople.setFaceGuid(peopleById.getFaceGuid());
|
||||
}
|
||||
sysPeople.setGuid(peopleById.getGuid());
|
||||
|
||||
//下发设备
|
||||
if(sysPeople.getBranchId()!=null){
|
||||
SysBranch branch=sysBranchService.selectSysBranchById(sysPeople.getBranchId());
|
||||
if (branch.getRuleId()!= null) {
|
||||
if (StringUtils.isNotEmpty(sysPeople.getBranchId())) {
|
||||
SysBranch branch = sysBranchService.selectSysBranchById(sysPeople.getBranchId());
|
||||
if (null != branch.getRuleId()) {
|
||||
//添加人员授权信息
|
||||
SysRule rule=sysRuleService.selectSysRuleById(branch.getRuleId());
|
||||
String data=sdkService.authDeviceNew(rule,sysPeople);
|
||||
SysRule rule = sysRuleService.selectSysRuleById(branch.getRuleId());
|
||||
int i = sdkService.authDeviceAddUpdate(rule, sysPeople, 1);
|
||||
if (i > 0) {
|
||||
return AjaxResult.error(i + "个设备下发失败!");
|
||||
}
|
||||
sysPeople.setDown(1L);
|
||||
if("".equals(data)){
|
||||
return AjaxResult.error("该规则未绑定设备!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return toAjax(sysPeopleService.updateSysPeople(sysPeople));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.dcsoft.system.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 设备下记录实体
|
||||
*/
|
||||
@Data
|
||||
public class SysEqDownRecord {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 设备ID
|
||||
*/
|
||||
private Long equipmentId;
|
||||
|
||||
/**
|
||||
* 人员ID
|
||||
*/
|
||||
private Long peopleId;
|
||||
|
||||
/**
|
||||
* 规则id
|
||||
*/
|
||||
private Long ruleId;
|
||||
|
||||
/**
|
||||
* 下发时间
|
||||
*/
|
||||
private Date downTime;
|
||||
|
||||
/**
|
||||
* 下发结果:0-成功,1-失败
|
||||
*/
|
||||
private Integer downResult;
|
||||
|
||||
/**
|
||||
* 下发回执
|
||||
*/
|
||||
private String msg;
|
||||
|
||||
/**
|
||||
* 操作类型:0:新增 1:修改 2:下发
|
||||
*/
|
||||
private Integer operType;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
private String equipmentName;
|
||||
|
||||
/**
|
||||
* 人员名称
|
||||
*/
|
||||
private String peopleName;
|
||||
|
||||
/**
|
||||
* 人员头像
|
||||
*/
|
||||
private String avatar;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.dcsoft.system.mapper;
|
||||
|
||||
import com.dcsoft.system.domain.SysEqDownRecord;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface SysEqDownRecordMapper {
|
||||
/**
|
||||
* 查询设备下发记录列表
|
||||
*
|
||||
* @param sysEqDownRecord 设备下发记录
|
||||
* @return 设备下发记录集合
|
||||
*/
|
||||
List<SysEqDownRecord> selectList(SysEqDownRecord sysEqDownRecord);
|
||||
|
||||
/**
|
||||
* 新增设备下发记录
|
||||
*
|
||||
* @param downRecordList 设备下发记录集合
|
||||
*/
|
||||
void insertBatch(@Param("list") List<SysEqDownRecord> downRecordList);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.dcsoft.system.service;
|
||||
|
||||
import com.dcsoft.system.domain.SysEqDownRecord;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ISysEqDownRecordService {
|
||||
List<SysEqDownRecord> pageList(SysEqDownRecord sysEqDownRecord);
|
||||
|
||||
void saveBatch(List<SysEqDownRecord> downRecordList);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.dcsoft.system.service.impl;
|
||||
|
||||
import com.dcsoft.system.domain.SysEqDownRecord;
|
||||
import com.dcsoft.system.mapper.SysEqDownRecordMapper;
|
||||
import com.dcsoft.system.service.ISysEqDownRecordService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.dcsoft.common.core.utils.PageUtils.startPage;
|
||||
|
||||
@Service
|
||||
public class SysEqDownRecordServiceImpl implements ISysEqDownRecordService {
|
||||
|
||||
@Autowired
|
||||
private SysEqDownRecordMapper sysEqDownRecordMapper;
|
||||
|
||||
@Override
|
||||
public List<SysEqDownRecord> pageList(SysEqDownRecord sysEqDownRecord) {
|
||||
|
||||
startPage();
|
||||
return sysEqDownRecordMapper.selectList(sysEqDownRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveBatch(List<SysEqDownRecord> downRecordList) {
|
||||
sysEqDownRecordMapper.insertBatch(downRecordList);
|
||||
}
|
||||
}
|
||||
@@ -123,4 +123,6 @@ public interface ISysSdkService {
|
||||
String authDeviceNews(SysRule rule, SysPeople sysPeople);
|
||||
|
||||
String authDevices(SysPeople people, SysEquipment equipment);
|
||||
|
||||
int authDeviceAddUpdate(SysRule rule, SysPeople sysPeople, Integer operType);
|
||||
}
|
||||
|
||||
@@ -3,8 +3,10 @@ package com.dcsoft.system.uniubi.service.impl;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.dcsoft.common.core.utils.CollUtil;
|
||||
import com.dcsoft.system.domain.*;
|
||||
import com.dcsoft.system.service.*;
|
||||
import com.dcsoft.system.uniubi.domain.Person;
|
||||
@@ -43,6 +45,9 @@ public class SysSdkServiceImpl implements ISysSdkService {
|
||||
@Autowired
|
||||
private ISysConfigService configService;
|
||||
|
||||
@Autowired
|
||||
private ISysEqDownRecordService sysEqDownRecordService;
|
||||
|
||||
/**
|
||||
* 卡权限创建接口
|
||||
*/
|
||||
@@ -687,6 +692,84 @@ public class SysSdkServiceImpl implements ISysSdkService {
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int authDeviceAddUpdate(SysRule rule, SysPeople people, Integer operType) {
|
||||
int i = 0;
|
||||
String[] pointIds = rule.getPointId().split(",");
|
||||
List<SysEquipment> equipList = new ArrayList<>();
|
||||
for (String point : pointIds) {
|
||||
SysEquipment equipment = new SysEquipment();
|
||||
equipment.setPointId(Long.parseLong(point));
|
||||
equipment.setFlag("0");
|
||||
equipment.setIsCj("0");
|
||||
equipment.setProductId(3L);
|
||||
List<SysEquipment> equipmentDtoList = equipmentService.selectSysEquipmentList(equipment);
|
||||
equipList.addAll(equipmentDtoList);
|
||||
}
|
||||
|
||||
List<SysEqDownRecord> downRecordList = new ArrayList<>();
|
||||
//通过规则获取绑定设备信息
|
||||
for (SysEquipment e : equipList) {
|
||||
SysEqDownRecord sysEqDownRecord = new SysEqDownRecord();
|
||||
sysEqDownRecord.setEquipmentId(e.getId());
|
||||
sysEqDownRecord.setPeopleId(people.getId());
|
||||
sysEqDownRecord.setRuleId(rule.getId());
|
||||
sysEqDownRecord.setOperType(operType);
|
||||
sysEqDownRecord.setDownTime(new Date());
|
||||
downRecordList.add(sysEqDownRecord);
|
||||
|
||||
|
||||
//将人员信息下发到设备
|
||||
Person person = new Person();
|
||||
person.setName(people.getName());
|
||||
person.setIdcardNum(people.getDoorNo());
|
||||
person.setiDNumber(people.getIdcard());
|
||||
person.setPhone(people.getPhone());
|
||||
person.setId(people.getGuid());
|
||||
|
||||
//删除人员信息
|
||||
if (operType == 0) {
|
||||
String data = this.personDelete(person.getId(), e.getIp(), e.getPassword());
|
||||
if (!verifyResult(data, sysEqDownRecord)) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//新增人员信息
|
||||
String data = this.personCreate(person, e.getIp(), e.getPassword());
|
||||
if (!verifyResult(data, sysEqDownRecord)) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
if (StringUtils.isNotEmpty(people.getFaceGuid())) {
|
||||
String dataImg = this.imageCreateUrl(people.getGuid(), people.getFaceGuid(), people.getAvatar(), e.getIp(), e.getPassword());
|
||||
if (!verifyResult(dataImg, sysEqDownRecord)) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//保存下发记录
|
||||
if (CollUtil.isNotEmpty(downRecordList)) {
|
||||
sysEqDownRecordService.saveBatch(downRecordList);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
private Boolean verifyResult(String data, SysEqDownRecord eqDownRecord) {
|
||||
eqDownRecord.setMsg(data);
|
||||
JSONObject jsons = JSONObject.parseObject(data);
|
||||
if (jsons != null && jsons.containsKey("code") && StrUtil.equals("LAN_SUS-0", jsons.getString("code"))) {
|
||||
eqDownRecord.setDownResult(0);
|
||||
return true;
|
||||
} else {
|
||||
eqDownRecord.setDownResult(1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String authDeviceNews(SysRule rule, SysPeople people) {
|
||||
String response="";
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.dcsoft.system.mapper.SysEqDownRecordMapper">
|
||||
|
||||
<resultMap type="SysEqDownRecord" id="SysEqDownRecordResult">
|
||||
<id property="id" column="id" />
|
||||
<result property="ruleId" column="rule_id" />
|
||||
<result property="equipmentId" column="equipment_id" />
|
||||
<result property="peopleId" column="people_id" />
|
||||
<result property="downTime" column="down_time" />
|
||||
<result property="downResult" column="down_result" />
|
||||
<result property="msg" column="msg" />
|
||||
<result property="operType" column="oper_type" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="equipmentName" column="equipment_name" />
|
||||
<result property="peopleName" column="people_name" />
|
||||
<result property="avatar" column="avatar" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 新增设备下发记录 -->
|
||||
<insert id="insertBatch" parameterType="java.util.List">
|
||||
insert into sys_equipment_down_record (
|
||||
rule_id,
|
||||
equipment_id,
|
||||
people_id,
|
||||
down_time,
|
||||
down_result,
|
||||
msg,
|
||||
oper_type,
|
||||
create_by,
|
||||
create_time
|
||||
)
|
||||
values
|
||||
<foreach collection="list" item="i" index="index" separator=",">
|
||||
(
|
||||
#{i.ruleId},
|
||||
#{i.equipmentId},
|
||||
#{i.peopleId},
|
||||
#{i.downTime},
|
||||
#{i.downResult},
|
||||
#{i.msg},
|
||||
#{i.operType},
|
||||
#{i.createBy},
|
||||
#{i.createTime}
|
||||
)
|
||||
</foreach>
|
||||
ON DUPLICATE KEY UPDATE
|
||||
rule_id = values(rule_id),
|
||||
equipment_id = values(equipment_id),
|
||||
people_id = values(people_id),
|
||||
down_time = values(down_time),
|
||||
down_result = values(down_result),
|
||||
msg = values(msg),
|
||||
oper_type = values(oper_type),
|
||||
create_by = values(create_by),
|
||||
create_time = values(create_time);
|
||||
</insert>
|
||||
|
||||
|
||||
<select id="selectList" parameterType="SysEqDownRecord" resultMap="SysEqDownRecordResult">
|
||||
select
|
||||
r.id,
|
||||
r.rule_id,
|
||||
r.equipment_id,
|
||||
r.people_id,
|
||||
r.down_time,
|
||||
r.down_result,
|
||||
r.msg,
|
||||
r.oper_type,
|
||||
r.create_by,
|
||||
r.create_time,
|
||||
e.`name` equipment_name,
|
||||
p.`name` people_name,
|
||||
p.avatar
|
||||
from sys_equipment_down_record r
|
||||
left join sys_equipment e on r.equipment_id = e.id
|
||||
left join sys_people p on r.people_id = p.id
|
||||
<where>
|
||||
<if test="equipmentId != null">
|
||||
and r.equipment_id = #{equipmentId}
|
||||
</if>
|
||||
<if test="peopleId != null">
|
||||
and r.people_id = #{peopleId}
|
||||
</if>
|
||||
<if test="peopleName != null and peopleName != ''">
|
||||
and p.`name` like concat('%',#{peopleName},'%')
|
||||
</if>
|
||||
<if test="downResult != null">
|
||||
and r.down_result = #{downResult}
|
||||
</if>
|
||||
</where>
|
||||
order by r.create_time desc,r.id desc
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user