优化新增/修改人员下发宇泛设备

This commit is contained in:
zc
2026-01-09 16:56:51 +08:00
parent f31b2b7618
commit 5493fefff1
9 changed files with 44 additions and 30 deletions

View File

@@ -212,23 +212,13 @@ public class SysPeopleController extends BaseController
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 (StringUtils.isNotEmpty(sysPeople.getBranchId()) && isDown) {
if (StringUtils.isNotEmpty(sysPeople.getBranchId())) {
SysBranch branch = sysBranchService.selectSysBranchById(sysPeople.getBranchId());
if (null != branch.getRuleId()) {
//添加人员授权信息
@@ -285,21 +275,28 @@ public class SysPeopleController extends BaseController
@Log(title = "人员管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
List<SysPeopleEqDown> list = sysEqDownRecordService.selectListByIds(null, Arrays.asList(ids));
if (CollUtil.isNotEmpty(list)) {
for (SysPeopleEqDown sysPeopleEqDown : list) {
if(sysPeopleEqDown.getDownResult() == 1) {
continue;
}
String data = sdkService.personDelete(sysPeopleEqDown.getGuid(), sysPeopleEqDown.getIp(), sysPeopleEqDown.getPassword());
JSONObject jsons = JSONObject.parseObject(data);
if (jsons == null || !jsons.containsKey("code") || !StrUtil.equals("LAN_SUS-0", jsons.getString("code"))) {
throw new ServiceException("人员删除失败:设备" + sysPeopleEqDown.getIp() + "网络异常");
List<SysPeople> peopleList = sysPeopleService.selectSysPeopleListByIds(Arrays.asList(ids));
if (CollUtil.isNotEmpty(peopleList)) {
String admitGuids = peopleList.stream().map(SysPeople::getGuid).collect(Collectors.joining(","));
if (StringUtils.isNotBlank(admitGuids)) {
log.info("设备删除人员:{}", admitGuids);
SysEquipment equipment = new SysEquipment();
equipment.setFlag("0");
equipment.setProductId(3L);
List<SysEquipment> list = equipmentService.selectSysEquipmentList(equipment);
for (SysEquipment e : list) {
String data = sdkService.personDelete(admitGuids, e.getIp(), e.getPassword());
JSONObject jsons = JSONObject.parseObject(data);
if (jsons == null || !jsons.containsKey("code") || !StrUtil.equals("LAN_SUS-0", jsons.getString("code"))) {
throw new ServiceException("人员删除失败:设备" + e.getIp() + "删除异常");
}
}
}
sysEqDownRecordService.deleteByIds(list.stream().map(SysPeopleEqDown::getId).collect(Collectors.toList()));
}
//删除下发记录
sysEqDownRecordService.deleteByPeopleIds(Arrays.asList(ids));
//暂未处理离线设备人员数据删除
return toAjax(sysPeopleService.deleteSysPeopleByIds(ids));
}

View File

@@ -32,5 +32,5 @@ public interface SysEqDownRecordMapper {
*/
List<SysPeopleEqDown> selectListByIds(@Param("ids") List<Long> ids, @Param("peopleIds") List<Long> peopleIds);
void deleteByIds(@Param("ids") List<Long> ids);
void deleteByPeopleIds(@Param("peopleIds") List<Long> peopleIds);
}

View File

@@ -112,4 +112,6 @@ public interface SysPeopleMapper
List<SysPeople> querySysPeopleInfo(Long userId);
Long selectAppSysPeople(SysUser sysUser);
List<SysPeople> selectSysPeopleListByIds(@Param("list") List<Long> list);
}

View File

@@ -12,5 +12,5 @@ public interface ISysEqDownRecordService {
List<SysPeopleEqDown> selectListByIds(List<Long> ids, List<Long> peopleIds);
void deleteByIds(List<Long> collect);
void deleteByPeopleIds(List<Long> peopleIds);
}

View File

@@ -117,4 +117,6 @@ public interface ISysPeopleService
List<SysPeople> querySysPeopleInfo(Long userId);
Long selectAppSysPeople(SysUser sysUser);
List<SysPeople> selectSysPeopleListByIds(List<Long> list);
}

View File

@@ -45,10 +45,10 @@ public class SysEqDownRecordServiceImpl implements ISysEqDownRecordService {
}
@Override
public void deleteByIds(List<Long> ids) {
if (CollUtil.isEmpty(ids)) {
public void deleteByPeopleIds(List<Long> peopleIds) {
if (CollUtil.isEmpty(peopleIds)) {
return;
}
sysEqDownRecordMapper.deleteByIds(ids);
sysEqDownRecordMapper.deleteByPeopleIds(peopleIds);
}
}

View File

@@ -18,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@@ -143,6 +144,11 @@ public class SysPeopleServiceImpl implements ISysPeopleService
return sysPeopleMapper.selectAppSysPeople(sysUser);
}
@Override
public List<SysPeople> selectSysPeopleListByIds(List<Long> list) {
return sysPeopleMapper.selectSysPeopleListByIds(list);
}
@Override
@DataScope(deptAlias = "d", userAlias = "u")
public List<SysPeople> selectSysPeopleLists(SysPeople sysPeople)

View File

@@ -59,9 +59,9 @@
create_time = values(create_time);
</insert>
<delete id="deleteByIds">
delete from sys_equipment_down_record where id in
<foreach collection="ids" item="id" index="index" open="(" close=")" separator=",">
<delete id="deleteByPeopleIds">
delete from sys_equipment_down_record where people_id in
<foreach collection="peopleIds" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
</delete>

View File

@@ -329,4 +329,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectAppSysPeople" resultType="java.lang.Long">
select id from sys_people where del_flag = '0' and (phone = #{phonenumber} or phone = #{userName})
</select>
<select id="selectSysPeopleListByIds" resultMap="SysPeopleResult">
select * from sys_people where id in
<foreach collection="list" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>