From 641a1652e86430073dc873a26c8daed0be7148bc Mon Sep 17 00:00:00 2001 From: zc Date: Fri, 9 Jan 2026 11:45:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=96=B0=E5=A2=9E/=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BA=BA=E5=91=98=E4=B8=8B=E5=8F=91=E5=AE=87=E6=B3=9B?= =?UTF-8?q?=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SysEqDownRecordController.java | 32 ++ .../controller/SysPeopleController.java | 477 +++--------------- .../dcsoft/system/domain/SysEqDownRecord.java | 77 +++ .../system/mapper/SysEqDownRecordMapper.java | 25 + .../service/ISysEqDownRecordService.java | 11 + .../impl/SysEqDownRecordServiceImpl.java | 30 ++ .../system/uniubi/service/ISysSdkService.java | 2 + .../service/impl/SysSdkServiceImpl.java | 83 +++ .../mapper/system/SysEqDownRecordMapper.xml | 98 ++++ 9 files changed, 436 insertions(+), 399 deletions(-) create mode 100644 dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/controller/SysEqDownRecordController.java create mode 100644 dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/domain/SysEqDownRecord.java create mode 100644 dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/mapper/SysEqDownRecordMapper.java create mode 100644 dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/service/ISysEqDownRecordService.java create mode 100644 dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/service/impl/SysEqDownRecordServiceImpl.java create mode 100644 dcsoft-modules/dcsoft-system/src/main/resources/mapper/system/SysEqDownRecordMapper.xml diff --git a/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/controller/SysEqDownRecordController.java b/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/controller/SysEqDownRecordController.java new file mode 100644 index 0000000..e76233d --- /dev/null +++ b/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/controller/SysEqDownRecordController.java @@ -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 list = sysEqDownRecordService.pageList(sysEqDownRecord); + return getDataTable(list); + } + + +} diff --git a/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/controller/SysPeopleController.java b/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/controller/SysPeopleController.java index 5a2e415..3de2823 100644 --- a/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/controller/SysPeopleController.java +++ b/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/controller/SysPeopleController.java @@ -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); - } - }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 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) { - //添加人员授权信息 - SysRule rule=sysRuleService.selectSysRuleById(branch.getRuleId()); - String data=sdkService.authDeviceNew(rule,sysPeople); - if("".equals(data)){ - return AjaxResult.error("该规则未绑定设备!"); - } - sysPeople.setDown(1L); - } - } - - if (CollUtil.isNotEmpty(sysPeople.getCarryStuffExamineList())) { - sysPeople.setCarryStuffExamine(String.join(",", sysPeople.getCarryStuffExamineList())); - } - i=sysPeopleService.insertSysPeople(sysPeople); - + if (StringUtils.isNotEmpty(sysPeople.getAvatar())) { + sysPeople.setFaceGuid(IdUtils.simpleUUID()); } + sysPeople.setGuid(IdUtils.simpleUUID()); + + //下发设备 + if (StringUtils.isNotEmpty(sysPeople.getBranchId())) { + SysBranch branch = sysBranchService.selectSysBranchById(sysPeople.getBranchId()); + if (null != branch.getRuleId()) { + //添加人员授权信息 + 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())); + } + + 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); - } - } - } 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 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")+""); - } - } + public AjaxResult edit(@RequestBody SysPeople sysPeople) { - //人像是否注册 - 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); - } - } - }else { - return error("默认设备设备已离线"); - } - } - } + SysPeople people = sysPeopleService.selectSysPeopleByGh(sysPeople.getGh()); + if (people != null && !people.getId().equals(sysPeople.getId())) { + return error("该工号已存在"); + } + + if (StringUtils.isNotEmpty(sysPeople.getDoorNo())) { + SysPeople doorNo = sysPeopleService.selectSysPeopleByDoorNo(sysPeople.getDoorNo()); + if (doorNo != null && !doorNo.getId().equals(sysPeople.getId())) { + return error("该门禁号已存在"); } } + + 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; + } + + 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); - sysPeople.setDown(1L); - if ("".equals(data)) { - return AjaxResult.error("该规则未绑定设备!"); + int i = sdkService.authDeviceAddUpdate(rule, sysPeople, 1); + if (i > 0) { + return AjaxResult.error(i + "个设备下发失败!"); } + sysPeople.setDown(1L); } } + 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 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); - sysPeople.setDown(1L); - if("".equals(data)){ - return AjaxResult.error("该规则未绑定设备!"); + SysRule rule = sysRuleService.selectSysRuleById(branch.getRuleId()); + int i = sdkService.authDeviceAddUpdate(rule, sysPeople, 1); + if (i > 0) { + return AjaxResult.error(i + "个设备下发失败!"); } + sysPeople.setDown(1L); } } + return toAjax(sysPeopleService.updateSysPeople(sysPeople)); } diff --git a/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/domain/SysEqDownRecord.java b/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/domain/SysEqDownRecord.java new file mode 100644 index 0000000..427f2c2 --- /dev/null +++ b/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/domain/SysEqDownRecord.java @@ -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; +} diff --git a/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/mapper/SysEqDownRecordMapper.java b/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/mapper/SysEqDownRecordMapper.java new file mode 100644 index 0000000..9bc47ee --- /dev/null +++ b/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/mapper/SysEqDownRecordMapper.java @@ -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 selectList(SysEqDownRecord sysEqDownRecord); + + /** + * 新增设备下发记录 + * + * @param downRecordList 设备下发记录集合 + */ + void insertBatch(@Param("list") List downRecordList); +} diff --git a/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/service/ISysEqDownRecordService.java b/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/service/ISysEqDownRecordService.java new file mode 100644 index 0000000..dd7a026 --- /dev/null +++ b/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/service/ISysEqDownRecordService.java @@ -0,0 +1,11 @@ +package com.dcsoft.system.service; + +import com.dcsoft.system.domain.SysEqDownRecord; + +import java.util.List; + +public interface ISysEqDownRecordService { + List pageList(SysEqDownRecord sysEqDownRecord); + + void saveBatch(List downRecordList); +} diff --git a/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/service/impl/SysEqDownRecordServiceImpl.java b/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/service/impl/SysEqDownRecordServiceImpl.java new file mode 100644 index 0000000..64ee2bf --- /dev/null +++ b/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/service/impl/SysEqDownRecordServiceImpl.java @@ -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 pageList(SysEqDownRecord sysEqDownRecord) { + + startPage(); + return sysEqDownRecordMapper.selectList(sysEqDownRecord); + } + + @Override + public void saveBatch(List downRecordList) { + sysEqDownRecordMapper.insertBatch(downRecordList); + } +} diff --git a/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/uniubi/service/ISysSdkService.java b/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/uniubi/service/ISysSdkService.java index b5f92b7..1abb331 100644 --- a/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/uniubi/service/ISysSdkService.java +++ b/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/uniubi/service/ISysSdkService.java @@ -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); } diff --git a/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/uniubi/service/impl/SysSdkServiceImpl.java b/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/uniubi/service/impl/SysSdkServiceImpl.java index bf5bbdd..3e51174 100644 --- a/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/uniubi/service/impl/SysSdkServiceImpl.java +++ b/dcsoft-modules/dcsoft-system/src/main/java/com/dcsoft/system/uniubi/service/impl/SysSdkServiceImpl.java @@ -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 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 equipmentDtoList = equipmentService.selectSysEquipmentList(equipment); + equipList.addAll(equipmentDtoList); + } + + List 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=""; diff --git a/dcsoft-modules/dcsoft-system/src/main/resources/mapper/system/SysEqDownRecordMapper.xml b/dcsoft-modules/dcsoft-system/src/main/resources/mapper/system/SysEqDownRecordMapper.xml new file mode 100644 index 0000000..4dc6fcd --- /dev/null +++ b/dcsoft-modules/dcsoft-system/src/main/resources/mapper/system/SysEqDownRecordMapper.xml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + insert into sys_equipment_down_record ( + rule_id, + equipment_id, + people_id, + down_time, + down_result, + msg, + oper_type, + create_by, + create_time + ) + values + + ( + #{i.ruleId}, + #{i.equipmentId}, + #{i.peopleId}, + #{i.downTime}, + #{i.downResult}, + #{i.msg}, + #{i.operType}, + #{i.createBy}, + #{i.createTime} + ) + + 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); + + + + + +