Merge branch 'master' of http://47.109.37.87:3000/by2025/SmartParks
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
This commit is contained in:
@@ -25,6 +25,8 @@ public class RemoteResidentPersonVo implements Serializable {
|
||||
|
||||
private Long gender;
|
||||
|
||||
private String phone;
|
||||
|
||||
private String idCard;
|
||||
|
||||
private Long authGroupId;
|
||||
|
@@ -25,6 +25,13 @@ public interface RemoteUserService {
|
||||
* @return 结果
|
||||
*/
|
||||
LoginUser getUserInfo(String username, String tenantId) throws UserException;
|
||||
/**
|
||||
* 通过用户id查询用户信息
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return 结果
|
||||
*/
|
||||
RemoteUserVo getUserInfoById(Long userId) throws UserException;
|
||||
|
||||
/**
|
||||
* 通过用户id查询用户信息
|
||||
|
@@ -2,6 +2,8 @@ package org.dromara.sis.api;
|
||||
|
||||
import org.dromara.sis.api.domain.RemotePersonAuth;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author lsm
|
||||
* @apiNote RemoteSisAuth
|
||||
@@ -10,4 +12,8 @@ import org.dromara.sis.api.domain.RemotePersonAuth;
|
||||
public interface RemoteSisAuth {
|
||||
|
||||
Boolean personAuth(RemotePersonAuth personAuth);
|
||||
|
||||
Boolean updatePersonAuth(RemotePersonAuth personAuth);
|
||||
|
||||
Boolean deletePersonAuth(Collection<Long> personId, Collection<Long> e8Ids);
|
||||
}
|
||||
|
@@ -27,6 +27,8 @@ public class RemotePersonAuth implements Serializable {
|
||||
|
||||
private String email;
|
||||
|
||||
private Long e8Id;
|
||||
|
||||
private Integer cardType = 1;
|
||||
|
||||
private String idCardNumber;
|
||||
|
@@ -62,7 +62,7 @@ public class MachineMaintainPlanController extends BaseController {
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("system:maintainPlan:query")
|
||||
//@SaCheckPermission("system:maintainPlan:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<MachineMaintainPlanVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable("id") Long id) {
|
||||
|
@@ -66,7 +66,8 @@ public class TbCommunityController extends BaseController {
|
||||
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||
Assert.notNull(loginUser, "获取账户信息失败!");
|
||||
Assert.notEmpty(loginUser.getTenantId(), "获取租户信息失败");
|
||||
return R.ok(tbCommunityService.tree(level, loginUser.getTenantId()));
|
||||
List<TreeNode<Long>> tree = tbCommunityService.tree(level, loginUser.getTenantId());
|
||||
return R.ok(tree);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -73,7 +73,7 @@ public class MachineMaintainPlan extends TenantEntity {
|
||||
private Date endDate;
|
||||
|
||||
/**
|
||||
* 状态(0启用,1停用)
|
||||
* 状态(1启用,0停用)
|
||||
*/
|
||||
private String state;
|
||||
|
||||
|
@@ -60,7 +60,7 @@ public class MeetAttachBo extends BaseEntity {
|
||||
* 状态
|
||||
*/
|
||||
@NotNull(message = "状态不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private int state;
|
||||
private Integer state;
|
||||
|
||||
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@ import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@@ -24,19 +25,19 @@ public class ResidentPersonBo extends BaseEntity {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@NotNull(message = "主键id不能为空", groups = { EditGroup.class })
|
||||
@NotNull(message = "主键id不能为空", groups = {EditGroup.class})
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
@NotBlank(message = "用户名称不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
@NotBlank(message = "用户名称不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 联系电话
|
||||
*/
|
||||
@NotBlank(message = "联系电话不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
@NotBlank(message = "联系电话不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String phone;
|
||||
/**
|
||||
* 人员类型
|
||||
@@ -46,13 +47,13 @@ public class ResidentPersonBo extends BaseEntity {
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
@NotNull(message = "性别不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
@NotNull(message = "性别不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private Long gender;
|
||||
|
||||
/**
|
||||
* 证件号
|
||||
*/
|
||||
@NotBlank(message = "证件号不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
@NotBlank(message = "证件号不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String idCard;
|
||||
|
||||
/**
|
||||
@@ -113,7 +114,7 @@ public class ResidentPersonBo extends BaseEntity {
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Long state=1L;
|
||||
private Long state = 1L;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
|
@@ -27,11 +27,10 @@ public class TbFloorBo extends BaseEntity {
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 单元编码
|
||||
* 建筑编码
|
||||
*/
|
||||
@NotNull(message = "单元编码不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long unitId;
|
||||
|
||||
@NotNull(message = "建筑编码不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long buildingId;
|
||||
/**
|
||||
* 楼层数名称
|
||||
*/
|
||||
|
@@ -52,7 +52,7 @@ public class TbVisitorManagementBo extends BaseEntity {
|
||||
@NotBlank(message = "拜访事由不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private String visitingReason;
|
||||
|
||||
@NotBlank(message = "类型不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
//@NotNull(message = "类型不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
|
@@ -39,6 +39,11 @@ public class MachineMaintainPlanStaffVo implements Serializable {
|
||||
*/
|
||||
@ExcelProperty(value = "保养执行计划人id")
|
||||
private Long userId;
|
||||
/**
|
||||
* 保养执行计划人名称
|
||||
*/
|
||||
@ExcelProperty(value = "保养执行计划人名称")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 保养计划id
|
||||
|
@@ -1,19 +1,15 @@
|
||||
package org.dromara.property.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.dromara.property.domain.MachineMaintainTaskDetail;
|
||||
import org.dromara.property.domain.vo.MachineMaintainTaskDetailVo;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
|
||||
|
||||
/**
|
||||
* 设备保养任务明细Mapper接口
|
||||
* 保养明细Mapper接口
|
||||
*
|
||||
* @author mocheng
|
||||
* @date 2025-07-16
|
||||
* @date 2025-07-30
|
||||
*/
|
||||
@Mapper
|
||||
public interface MachineMaintainTaskDetailMapper extends MPJBaseMapper<MachineMaintainTaskDetail> {
|
||||
public interface MachineMaintainTaskDetailMapper extends BaseMapperPlus<MachineMaintainTaskDetail, MachineMaintainTaskDetailVo> {
|
||||
|
||||
}
|
||||
|
@@ -1,13 +1,17 @@
|
||||
package org.dromara.property.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
@@ -16,8 +20,11 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.property.domain.InspectionPlan;
|
||||
import org.dromara.property.domain.InspectionPlanStaff;
|
||||
import org.dromara.property.domain.InspectionRoute;
|
||||
import org.dromara.property.domain.MachineMaintainPlanStaff;
|
||||
import org.dromara.property.domain.bo.InspectionPlanBo;
|
||||
import org.dromara.property.domain.bo.InspectionPlanStaffBo;
|
||||
import org.dromara.property.domain.bo.MachineMaintainPlanBo;
|
||||
import org.dromara.property.domain.bo.MachineMaintainPlanStaffBo;
|
||||
import org.dromara.property.domain.vo.InspectionPlanDetailVo;
|
||||
import org.dromara.property.domain.vo.InspectionPlanStaffVo;
|
||||
import org.dromara.property.domain.vo.InspectionPlanVo;
|
||||
@@ -27,6 +34,8 @@ import org.dromara.property.mapper.InspectionPlanStaffMapper;
|
||||
import org.dromara.property.mapper.InspectionRouteMapper;
|
||||
import org.dromara.property.mapper.ResidentPersonMapper;
|
||||
import org.dromara.property.service.IInspectionPlanService;
|
||||
import org.dromara.system.api.RemoteUserService;
|
||||
import org.dromara.system.api.domain.vo.RemoteUserVo;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -51,6 +60,9 @@ public class InspectionPlanServiceImpl implements IInspectionPlanService {
|
||||
private final InspectionPlanStaffMapper inspectionPlanStaffMapper;
|
||||
private final InspectionRouteMapper inspectionRouteMapper;
|
||||
|
||||
@DubboReference
|
||||
private RemoteUserService remoteUserService;
|
||||
|
||||
/**
|
||||
* 查询巡检计划
|
||||
*
|
||||
@@ -71,12 +83,12 @@ public class InspectionPlanServiceImpl implements IInspectionPlanService {
|
||||
if (CollectionUtil.isNotEmpty(userIdlist)) {
|
||||
new ServiceException("执行计划人不存在");
|
||||
}
|
||||
List<ResidentPersonVo> residentPersonVolist = residentPersonMapper.selectVoByIds(userIdlist);
|
||||
if (CollectionUtil.isNotEmpty(residentPersonVolist)) {
|
||||
List<RemoteUserVo> remoteUserVoList = remoteUserService.selectListByIds(userIdlist);
|
||||
if (CollectionUtil.isNotEmpty(remoteUserVoList)) {
|
||||
inspectionPlanStaffVos.stream().forEach(s -> {
|
||||
ResidentPersonVo residentPersonVo = residentPersonVolist.stream()
|
||||
.filter(vo -> vo.getId() != null && vo.getId().equals(s.getUserId())).findFirst().orElse(null);
|
||||
s.setUserName(residentPersonVo.getUserName());
|
||||
RemoteUserVo remoteUserVo = remoteUserVoList.stream()
|
||||
.filter(vo -> vo.getUserId() != null && vo.getUserId().equals(s.getUserId())).findFirst().orElse(null);
|
||||
s.setUserName(remoteUserVo.getNickName());
|
||||
});
|
||||
inspectionPlanDetailVo.setInspectionPlanStaffVoList(inspectionPlanStaffVos);
|
||||
}
|
||||
@@ -138,7 +150,6 @@ public class InspectionPlanServiceImpl implements IInspectionPlanService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean insertByBo(InspectionPlanBo bo) {
|
||||
InspectionPlan add = MapstructUtils.convert(bo, InspectionPlan.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
@@ -164,15 +175,23 @@ public class InspectionPlanServiceImpl implements IInspectionPlanService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean updateByBo(InspectionPlanBo bo) {
|
||||
InspectionPlan update = MapstructUtils.convert(bo, InspectionPlan.class);
|
||||
validEntityBeforeSave(update);
|
||||
validEntityBeforebo(bo.getId(),bo);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(InspectionPlan entity) {
|
||||
private void validEntityBeforebo(Long id,InspectionPlanBo bo) {
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
Assert.isTrue(CollUtil.isNotEmpty(bo.getInspectionPlanStaffBoList()), "巡检人员不存在");
|
||||
QueryWrapper<InspectionPlanStaff> staffLambdaQueryWrapper = new QueryWrapper<>();
|
||||
staffLambdaQueryWrapper.eq("inspection_plan_id", id);
|
||||
inspectionPlanStaffMapper.delete(staffLambdaQueryWrapper);
|
||||
List<InspectionPlanStaffBo> inspectionPlanStaffBoList = bo.getInspectionPlanStaffBoList();
|
||||
inspectionPlanStaffBoList.stream().forEach(s->{
|
||||
s.setInspectionPlanId(id);
|
||||
});
|
||||
inspectionPlanStaffMapper.insertBatch(BeanUtil.copyToList(inspectionPlanStaffBoList, InspectionPlanStaff.class));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,8 +1,13 @@
|
||||
package org.dromara.property.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.ObjectUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
@@ -22,11 +27,14 @@ import org.dromara.property.domain.vo.MachineMaintainPlanVo;
|
||||
import org.dromara.property.mapper.MachineMaintainPlanMapper;
|
||||
import org.dromara.property.mapper.MachineMaintainPlanStaffMapper;
|
||||
import org.dromara.property.service.IMachineMaintainPlanService;
|
||||
import org.dromara.system.api.RemoteUserService;
|
||||
import org.dromara.system.api.domain.vo.RemoteUserVo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 设备保养计划Service业务层处理
|
||||
@@ -41,6 +49,8 @@ public class MachineMaintainPlanServiceImpl implements IMachineMaintainPlanServi
|
||||
|
||||
private final MachineMaintainPlanMapper baseMapper;
|
||||
private final MachineMaintainPlanStaffMapper machineMaintainPlanStaffMapper;
|
||||
@DubboReference
|
||||
private RemoteUserService remoteUserService;
|
||||
|
||||
/**
|
||||
* 查询设备保养计划
|
||||
@@ -49,15 +59,36 @@ public class MachineMaintainPlanServiceImpl implements IMachineMaintainPlanServi
|
||||
* @return 设备保养计划
|
||||
*/
|
||||
@Override
|
||||
public MachineMaintainPlanVo queryById(Long id){
|
||||
public MachineMaintainPlanVo queryById(Long id) {
|
||||
MachineMaintainPlanVo machineMaintainPlanVo = baseMapper.selectVoById(id);
|
||||
LambdaQueryWrapper<MachineMaintainPlanStaff> planQueryWrapper = new LambdaQueryWrapper<>();
|
||||
planQueryWrapper.eq(MachineMaintainPlanStaff::getMaintainPlanId,id);
|
||||
planQueryWrapper.eq(MachineMaintainPlanStaff::getMaintainPlanId, id);
|
||||
List<MachineMaintainPlanStaffVo> machineMaintainPlanStaffVos = machineMaintainPlanStaffMapper.selectVoList(planQueryWrapper);
|
||||
machineMaintainPlanVo.setMachineMaintainPlanStaffVos(machineMaintainPlanStaffVos );
|
||||
List<Long> userIdlist = machineMaintainPlanStaffVos.stream()
|
||||
.map(vo -> vo.getUserId())
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
List<RemoteUserVo> remoteUserVoList = remoteUserService.selectListByIds(userIdlist);
|
||||
machineMaintainPlanStaffVos.stream().forEach(s -> {
|
||||
disposeMaintainPlanStaffVo(s, remoteUserVoList);
|
||||
});
|
||||
machineMaintainPlanVo.setMachineMaintainPlanStaffVos(machineMaintainPlanStaffVos);
|
||||
return machineMaintainPlanVo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理保养人
|
||||
*
|
||||
* @param machineMaintainPlanStaffVos
|
||||
*/
|
||||
private void disposeMaintainPlanStaffVo(MachineMaintainPlanStaffVo machineMaintainPlanStaffVos, List<RemoteUserVo> remoteUserVoList) {
|
||||
if (ObjectUtils.isNotNull(machineMaintainPlanStaffVos.getUserId()) && CollUtil.isNotEmpty(remoteUserVoList)) {
|
||||
RemoteUserVo remoteUserVo = remoteUserVoList.stream()
|
||||
.filter(vo -> vo.getUserId() != null && vo.getUserId().equals(machineMaintainPlanStaffVos.getUserId())).findFirst().orElse(null);
|
||||
machineMaintainPlanStaffVos.setUserName(remoteUserVo.getNickName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询设备保养计划列表
|
||||
*
|
||||
@@ -111,8 +142,7 @@ public class MachineMaintainPlanServiceImpl implements IMachineMaintainPlanServi
|
||||
@Override
|
||||
public Boolean insertByBo(MachineMaintainPlanBo bo) {
|
||||
MachineMaintainPlan add = MapstructUtils.convert(bo, MachineMaintainPlan.class);
|
||||
add.setState("0");
|
||||
validEntityBeforeSave(add);
|
||||
add.setState("1");
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
@@ -121,7 +151,10 @@ public class MachineMaintainPlanServiceImpl implements IMachineMaintainPlanServi
|
||||
for (MachineMaintainPlanStaffBo staffBo : machineMaintainPlanStaffBoList) {
|
||||
staffBo.setMaintainPlanId(add.getId());
|
||||
}
|
||||
machineMaintainPlanStaffMapper.insertBatch(BeanUtil.copyToList(machineMaintainPlanStaffBoList, MachineMaintainPlanStaff.class));
|
||||
List<MachineMaintainPlanStaff> machineMaintainPlanStaffs = BeanUtil.copyToList(machineMaintainPlanStaffBoList, MachineMaintainPlanStaff.class);
|
||||
|
||||
machineMaintainPlanStaffMapper.insertBatch(machineMaintainPlanStaffs);
|
||||
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
@@ -136,16 +169,24 @@ public class MachineMaintainPlanServiceImpl implements IMachineMaintainPlanServi
|
||||
@Override
|
||||
public Boolean updateByBo(MachineMaintainPlanBo bo) {
|
||||
MachineMaintainPlan update = MapstructUtils.convert(bo, MachineMaintainPlan.class);
|
||||
validEntityBeforeSave(update);
|
||||
validEntityBeforebo(update.getId(), bo);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(MachineMaintainPlan entity){
|
||||
private void validEntityBeforebo(Long id, MachineMaintainPlanBo bo) {
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
|
||||
Assert.isTrue(CollUtil.isNotEmpty(bo.getMachineMaintainPlanStaffBoList()), "巡检人员不存在");
|
||||
QueryWrapper<MachineMaintainPlanStaff> staffLambdaQueryWrapper = new QueryWrapper<>();
|
||||
staffLambdaQueryWrapper.eq("maintain_plan_id", id);
|
||||
machineMaintainPlanStaffMapper.delete(staffLambdaQueryWrapper);
|
||||
List<MachineMaintainPlanStaffBo> machineMaintainPlanStaffBoList = bo.getMachineMaintainPlanStaffBoList();
|
||||
machineMaintainPlanStaffBoList.stream().forEach(s->{
|
||||
s.setMaintainPlanId(id);
|
||||
});
|
||||
machineMaintainPlanStaffMapper.insertBatch(BeanUtil.copyToList(machineMaintainPlanStaffBoList, MachineMaintainPlanStaff.class));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,7 +198,7 @@ public class MachineMaintainPlanServiceImpl implements IMachineMaintainPlanServi
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
if (isValid) {
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
|
@@ -1,9 +1,5 @@
|
||||
package org.dromara.property.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.yulichang.query.MPJLambdaQueryWrapper;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
@@ -13,7 +9,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.property.domain.MachineMaintainTask;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.property.domain.bo.MachineMaintainTaskDetailBo;
|
||||
import org.dromara.property.domain.vo.MachineMaintainTaskDetailVo;
|
||||
@@ -26,10 +21,10 @@ import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 设备保养任务明细Service业务层处理
|
||||
* 保养明细Service业务层处理
|
||||
*
|
||||
* @author mocheng
|
||||
* @date 2025-07-16
|
||||
* @date 2025-07-30
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@@ -39,70 +34,66 @@ public class MachineMaintainTaskDetailServiceImpl implements IMachineMaintainTas
|
||||
private final MachineMaintainTaskDetailMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询设备保养任务明细
|
||||
* 查询保养明细
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 设备保养任务明细
|
||||
* @return 保养明细
|
||||
*/
|
||||
@Override
|
||||
public MachineMaintainTaskDetailVo queryById(Long id){
|
||||
MachineMaintainTaskDetail machineMaintainTaskDetail = baseMapper.selectById(id);
|
||||
MachineMaintainTaskDetailVo machineMaintainTaskDetailVo = BeanUtil.copyProperties(machineMaintainTaskDetail, MachineMaintainTaskDetailVo.class);
|
||||
return machineMaintainTaskDetailVo;
|
||||
return baseMapper.selectVoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询设备保养任务明细列表
|
||||
* 分页查询保养明细列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @param pageQuery 分页参数
|
||||
* @return 设备保养任务明细分页列表
|
||||
* @return 保养明细分页列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<MachineMaintainTaskDetailVo> queryPageList(MachineMaintainTaskDetailBo bo, PageQuery pageQuery) {
|
||||
MPJLambdaWrapper<MachineMaintainTaskDetail> lqw = buildQueryWrapper(bo);
|
||||
IPage<MachineMaintainTaskDetailVo> result = baseMapper.selectJoinPage(pageQuery.build(),MachineMaintainTaskDetailVo.class, lqw);
|
||||
LambdaQueryWrapper<MachineMaintainTaskDetail> lqw = buildQueryWrapper(bo);
|
||||
Page<MachineMaintainTaskDetailVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询符合条件的设备保养任务明细列表
|
||||
* 查询符合条件的保养明细列表
|
||||
*
|
||||
* @param bo 查询条件
|
||||
* @return 设备保养任务明细列表
|
||||
* @return 保养明细列表
|
||||
*/
|
||||
@Override
|
||||
public List<MachineMaintainTaskDetailVo> queryList(MachineMaintainTaskDetailBo bo) {
|
||||
MPJLambdaWrapper<MachineMaintainTaskDetail> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectJoinList(MachineMaintainTaskDetailVo.class, lqw);
|
||||
LambdaQueryWrapper<MachineMaintainTaskDetail> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private MPJLambdaWrapper<MachineMaintainTaskDetail> buildQueryWrapper(MachineMaintainTaskDetailBo bo) {
|
||||
return new MPJLambdaWrapper<MachineMaintainTaskDetail>()
|
||||
.orderByAsc(MachineMaintainTaskDetail::getId)
|
||||
.eq(bo.getTaskId() != null, MachineMaintainTaskDetail::getTaskId, bo.getTaskId())
|
||||
.eq(bo.getMachineId() != null, MachineMaintainTaskDetail::getMachineId, bo.getMachineId())
|
||||
.eq(StringUtils.isNotBlank(bo.getSendFlag()), MachineMaintainTaskDetail::getSendFlag, bo.getSendFlag())
|
||||
.eq(bo.getSortNumber() != null, MachineMaintainTaskDetail::getSortNumber, bo.getSortNumber())
|
||||
.eq(StringUtils.isNotBlank(bo.getState()), MachineMaintainTaskDetail::getState, bo.getState())
|
||||
.eq(StringUtils.isNotBlank(bo.getSearchValue()), MachineMaintainTaskDetail::getSearchValue, bo.getSearchValue())
|
||||
.selectAll(MachineMaintainTaskDetail.class)
|
||||
.select(MachineMaintainTask::getMaintainTaskNo)
|
||||
.leftJoin(MachineMaintainTask.class, MachineMaintainTask::getId, MachineMaintainTaskDetail::getTaskId);
|
||||
private LambdaQueryWrapper<MachineMaintainTaskDetail> buildQueryWrapper(MachineMaintainTaskDetailBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<MachineMaintainTaskDetail> lqw = Wrappers.lambdaQuery();
|
||||
lqw.orderByAsc(MachineMaintainTaskDetail::getId);
|
||||
lqw.eq(bo.getTaskId() != null, MachineMaintainTaskDetail::getTaskId, bo.getTaskId());
|
||||
lqw.eq(bo.getMachineId() != null, MachineMaintainTaskDetail::getMachineId, bo.getMachineId());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getSendFlag()), MachineMaintainTaskDetail::getSendFlag, bo.getSendFlag());
|
||||
lqw.eq(bo.getSortNumber() != null, MachineMaintainTaskDetail::getSortNumber, bo.getSortNumber());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getState()), MachineMaintainTaskDetail::getState, bo.getState());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getSearchValue()), MachineMaintainTaskDetail::getSearchValue, bo.getSearchValue());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增设备保养任务明细
|
||||
* 新增保养明细
|
||||
*
|
||||
* @param bo 设备保养任务明细
|
||||
* @param bo 保养明细
|
||||
* @return 是否新增成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(MachineMaintainTaskDetailBo bo) {
|
||||
MachineMaintainTaskDetail add = MapstructUtils.convert(bo, MachineMaintainTaskDetail.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = this.insertByBo(bo);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
@@ -110,16 +101,16 @@ public class MachineMaintainTaskDetailServiceImpl implements IMachineMaintainTas
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设备保养任务明细
|
||||
* 修改保养明细
|
||||
*
|
||||
* @param bo 设备保养任务明细
|
||||
* @param bo 保养明细
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(MachineMaintainTaskDetailBo bo) {
|
||||
MachineMaintainTaskDetail update = MapstructUtils.convert(bo, MachineMaintainTaskDetail.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update)>0;
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,7 +121,7 @@ public class MachineMaintainTaskDetailServiceImpl implements IMachineMaintainTas
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验并批量删除设备保养任务明细信息
|
||||
* 校验并批量删除保养明细信息
|
||||
*
|
||||
* @param ids 待删除的主键集合
|
||||
* @param isValid 是否进行有效性校验
|
||||
|
@@ -83,7 +83,7 @@ public class MeetAttachServiceImpl implements IMeetAttachService {
|
||||
lqw.eq(bo.getPrice() != null, MeetAttach::getPrice, bo.getPrice());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getUnit()), MeetAttach::getUnit, bo.getUnit());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getType()), MeetAttach::getType, bo.getType());
|
||||
lqw.eq(MeetAttach::getState, bo.getState());
|
||||
lqw.eq(ObjectUtil.isNotEmpty(bo.getState()),MeetAttach::getState, bo.getState());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
|
@@ -142,7 +142,7 @@ public class MeetServiceImpl implements IMeetService {
|
||||
lqw.orderByAsc(Meet::getId);
|
||||
lqw.like(StringUtils.isNotBlank(bo.getName()), Meet::getName, bo.getName());
|
||||
// lqw.eq(StringUtils.isNotBlank(bo.getLocation()), Meet::getLocation, bo.getLocation());
|
||||
// lqw.eq(bo.getPersonNumber() != null, Meet::getPersonNumber, bo.getPersonNumber());
|
||||
lqw.eq(bo.getPersonNumber() != null, Meet::getPersonNumber, bo.getPersonNumber());
|
||||
// lqw.eq(bo.getBaseService() != null, Meet::getBaseService, bo.getBaseService());
|
||||
// lqw.eq(bo.getBasePrice() != null, Meet::getBasePrice, bo.getBasePrice());
|
||||
lqw.eq(bo.getPrincipals() != null, Meet::getPrincipals, bo.getPrincipals());
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package org.dromara.property.service.impl;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
@@ -28,6 +29,8 @@ import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 入驻员工Service业务层处理
|
||||
@@ -159,15 +162,60 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
|
||||
@Override
|
||||
public Boolean updateByBo(ResidentPersonBo bo) {
|
||||
ResidentPerson update = MapstructUtils.convert(bo, ResidentPerson.class);
|
||||
validEntityBeforeUpdate(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
assert update != null;
|
||||
|
||||
boolean flag;
|
||||
// 人脸照片存在时,才同步修改授权
|
||||
if (update.getAuthGroupId() != null && update.getAuthEndDate() != null && update.getImg() != null) {
|
||||
ResidentPersonVo vo = queryById(update.getId());
|
||||
Long e8Id = vo.getEEightId();
|
||||
flag = baseMapper.updateById(update) > 0;
|
||||
|
||||
// 显式移除e8id
|
||||
LambdaUpdateWrapper<ResidentPerson> lqw = new LambdaUpdateWrapper<>();
|
||||
lqw.eq(ResidentPerson::getId, update.getId())
|
||||
.set(ResidentPerson::getEEightId, null);
|
||||
baseMapper.update(lqw);
|
||||
|
||||
|
||||
if (flag) {
|
||||
log.info("开始修改授权记录, {}", bo.getUserName());
|
||||
RemotePersonAuth personAuth = new RemotePersonAuth();
|
||||
personAuth.setId(update.getId());
|
||||
personAuth.setName(update.getUserName());
|
||||
personAuth.setSex(update.getGender().intValue());
|
||||
personAuth.setPhone(update.getPhone());
|
||||
personAuth.setEmail(update.getEmail());
|
||||
personAuth.setIdCardNumber(update.getIdCard());
|
||||
personAuth.setOssId(update.getImg());
|
||||
personAuth.setCarNumber(update.getCarNumber());
|
||||
personAuth.setE8Id(e8Id);
|
||||
|
||||
personAuth.setAuthGroupId(update.getAuthGroupId());
|
||||
personAuth.setAuthBegDate(update.getAuthBegDate());
|
||||
personAuth.setAuthEndDate(update.getAuthEndDate());
|
||||
|
||||
Boolean auth = remoteSisAuth.updatePersonAuth(personAuth);
|
||||
Assert.isTrue(auth, "修改授权记录失败!");
|
||||
}
|
||||
|
||||
} else {
|
||||
flag = baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
Assert.isTrue(flag, "修改入驻员工失败!");
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeUpdate(ResidentPerson entity) {
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
LambdaQueryWrapper<ResidentPerson> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(ResidentPerson::getIdCard, entity.getIdCard())
|
||||
.eq(ResidentPerson::getUnitId, entity.getUnitId());
|
||||
boolean exists = baseMapper.exists(lqw);
|
||||
Assert.isTrue(!exists, "当前单位,{}已存在!", entity.getUserName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,9 +248,12 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
|
||||
.anyMatch(vo -> vo.getState() == 1); // 遇到第一个启用人员立即返回
|
||||
Assert.isTrue(!hasEnabled, "当前存在人员状态为启用,请核对后再试!");
|
||||
|
||||
boolean hasE8 = list.stream()
|
||||
.anyMatch(vo -> vo.getEEightId() != null); // 遇到第一个e8人员立即返回
|
||||
Assert.isTrue(!hasE8, "当前存在人员已下发权限,请删除通行权限后再试!");
|
||||
Collection<Long> e8Ids = list.stream()
|
||||
.map(ResidentPersonVo::getEEightId)
|
||||
.filter(Objects::nonNull)
|
||||
.toList();
|
||||
boolean auth = remoteSisAuth.deletePersonAuth(ids, e8Ids);
|
||||
Assert.isTrue(auth, "删除授权记录失败!");
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
@@ -226,7 +277,7 @@ public class ResidentPersonServiceImpl implements IResidentPersonService {
|
||||
* @return List<ResidentPersonVo>
|
||||
*/
|
||||
@Override
|
||||
public List<ResidentPersonVo> queryUnAuthPerson(){
|
||||
public List<ResidentPersonVo> queryUnAuthPerson() {
|
||||
LambdaQueryWrapper<ResidentPerson> lqw = Wrappers.lambdaQuery();
|
||||
lqw.isNotNull(ResidentPerson::getImg)
|
||||
.ne(ResidentPerson::getImg, "")
|
||||
|
@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
@@ -27,6 +28,8 @@ import org.dromara.property.mapper.ServiceWorkOrdersMapper;
|
||||
import org.dromara.property.mapper.ServiceWorkOrdersRecordMapper;
|
||||
import org.dromara.property.mapper.ServiceWorkOrdersTypeMapper;
|
||||
import org.dromara.property.service.IServiceWorkOrdersService;
|
||||
import org.dromara.system.api.RemoteUserService;
|
||||
import org.dromara.system.api.domain.vo.RemoteUserVo;
|
||||
import org.dromara.system.api.model.LoginUser;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -52,6 +55,8 @@ public class ServiceWorkOrdersServiceImpl implements IServiceWorkOrdersService {
|
||||
private final ServiceWorkOrdersTypeMapper typesMapper;
|
||||
private final ResidentPersonMapper residentPersonMapper;
|
||||
private final ServiceWorkOrdersRecordMapper workOrdersRecordMapper;
|
||||
@DubboReference
|
||||
private RemoteUserService remoteUserService;
|
||||
|
||||
/**
|
||||
* 查询【工单处理】
|
||||
@@ -70,23 +75,24 @@ public class ServiceWorkOrdersServiceImpl implements IServiceWorkOrdersService {
|
||||
if (Objects.nonNull(serviceWorkOrdersTypeVo)) {
|
||||
serviceWorkOrdersInfoVo.setTypeName(serviceWorkOrdersTypeVo.getOrderTypeName());
|
||||
}
|
||||
ResidentPersonVo residentPersonHandler = residentPersonMapper.selectVoById(Long.valueOf(serviceWorkOrdersVo.getHandler()));
|
||||
if (Objects.nonNull(residentPersonHandler)) {
|
||||
serviceWorkOrdersInfoVo.setHandlerText(residentPersonHandler.getUserName());
|
||||
serviceWorkOrdersInfoVo.setHandlerPhone(residentPersonHandler.getPhone());
|
||||
//ResidentPersonVo residentPersonHandler = residentPersonMapper.selectVoById(Long.valueOf(serviceWorkOrdersVo.getHandler()));
|
||||
|
||||
RemoteUserVo userInfo = remoteUserService.getUserInfoById(Long.valueOf(serviceWorkOrdersVo.getHandler()));
|
||||
if (ObjectUtil.isNotEmpty(userInfo)) {
|
||||
serviceWorkOrdersInfoVo.setHandlerText(userInfo.getNickName());
|
||||
serviceWorkOrdersInfoVo.setHandlerPhone(userInfo.getPhonenumber());
|
||||
}
|
||||
//查询工单处理记录
|
||||
List<ServiceWorkOrdersRecordVo> serviceWorkOrdersRecordVoList = workOrdersRecordMapper.selectVoList(new LambdaQueryWrapper<ServiceWorkOrdersRecord>().eq(ServiceWorkOrdersRecord::getOrderId, id));
|
||||
if (CollUtil.isNotEmpty(serviceWorkOrdersRecordVoList)) {
|
||||
List<ServiceWorkOrdersRecordInfoVo> serviceWorkOrdersRecordInfoVos = BeanUtil.copyToList(serviceWorkOrdersRecordVoList, ServiceWorkOrdersRecordInfoVo.class);
|
||||
List<Long> residentPersonIdList = serviceWorkOrdersRecordInfoVos.stream().map(vo -> vo.getHandler()).distinct().collect(Collectors.toList());
|
||||
List<ResidentPerson> residentPeople = residentPersonMapper.selectByIds(residentPersonIdList);
|
||||
// List<ResidentPerson> residentPeople = residentPersonMapper.selectByIds(residentPersonIdList);
|
||||
List<RemoteUserVo> remoteUserVos = remoteUserService.selectListByIds(residentPersonIdList);
|
||||
serviceWorkOrdersRecordInfoVos.stream().forEach(workOrdersRecordVo -> {
|
||||
ResidentPerson residentPerson = residentPeople.stream().filter(vo -> vo.getId() != null && vo.getId().equals(serviceWorkOrdersVo.getHandler())).findFirst().orElse(null);
|
||||
workOrdersRecordVo.setHandlerName(Objects.nonNull(residentPerson) ? residentPerson.getUserName() : null);
|
||||
if (Objects.nonNull(serviceWorkOrdersTypeVo)) {
|
||||
workOrdersRecordVo.setInitiatorPeople(serviceWorkOrdersVo.getInitiatorPeople());
|
||||
}
|
||||
RemoteUserVo remoteUserVo = remoteUserVos.stream().filter(vo -> vo.getUserId() != null && vo.getUserId().equals(serviceWorkOrdersVo.getHandler())).findFirst().orElse(null);
|
||||
workOrdersRecordVo.setHandlerName(Objects.nonNull(remoteUserVo) ? remoteUserVo.getNickName() : null);
|
||||
workOrdersRecordVo.setInitiatorPeople(Objects.nonNull(serviceWorkOrdersTypeVo)?serviceWorkOrdersVo.getInitiatorPeople():null);
|
||||
if (workOrdersRecordVo.getStatus().equals("1") || workOrdersRecordVo.getStatus().equals("2")) {
|
||||
serviceWorkOrdersInfoVo.setDispatchTime(workOrdersRecordVo.getCreateTime());
|
||||
}
|
||||
@@ -122,7 +128,7 @@ public class ServiceWorkOrdersServiceImpl implements IServiceWorkOrdersService {
|
||||
s.setTypeName(ObjectUtil.isNotNull(serviceWorkOrdersTypeVo) ? serviceWorkOrdersTypeVo.getOrderTypeName() : null);
|
||||
serviceWorkOrdersVoList.add(s);
|
||||
});
|
||||
return TableDataInfo.build(new Page<ServiceWorkOrdersVo>().setRecords(serviceWorkOrdersVoList));
|
||||
return TableDataInfo.build(new Page<ServiceWorkOrdersVo>().setRecords(serviceWorkOrdersVoList).setTotal(result.getTotal()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -177,7 +183,7 @@ public class ServiceWorkOrdersServiceImpl implements IServiceWorkOrdersService {
|
||||
ServiceWorkOrdersRecord serviceWorkOrdersRecord = new ServiceWorkOrdersRecord();
|
||||
serviceWorkOrdersRecord.setOrderId(add.getId());
|
||||
serviceWorkOrdersRecord.setStatus(add.getStatus());
|
||||
serviceWorkOrdersRecord.setHandler(add.getHandler());
|
||||
//serviceWorkOrdersRecord.setHandler(add.getHandler());
|
||||
workOrdersRecordMapper.insert(serviceWorkOrdersRecord);
|
||||
}
|
||||
return flag;
|
||||
@@ -210,12 +216,6 @@ public class ServiceWorkOrdersServiceImpl implements IServiceWorkOrdersService {
|
||||
* 修改前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeUpdate(ServiceWorkOrders entity) {
|
||||
LambdaQueryWrapper<ResidentPerson> residentPersonQueryWrapper = new LambdaQueryWrapper<>();
|
||||
residentPersonQueryWrapper.eq(ResidentPerson::getUserId, entity.getHandler());
|
||||
residentPersonQueryWrapper.last("LIMIT 1");
|
||||
ResidentPerson residentPerson = residentPersonMapper.selectOne(residentPersonQueryWrapper);
|
||||
Assert.notNull(residentPerson, "该用户未入住不能抢单");
|
||||
entity.setHandler(residentPerson.getId());
|
||||
LambdaQueryWrapper<ServiceWorkOrdersRecord> ordersLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
ordersLambdaQueryWrapper.eq(ServiceWorkOrdersRecord::getOrderId, entity.getId());
|
||||
ordersLambdaQueryWrapper.eq(ServiceWorkOrdersRecord::getStatus, entity.getStatus());
|
||||
@@ -314,7 +314,7 @@ public class ServiceWorkOrdersServiceImpl implements IServiceWorkOrdersService {
|
||||
|
||||
// 获取满意度分布
|
||||
List<ServiceWorkOrderAnalysisVo.SatisfactionChartVo> satisfactionRateList = calculateSatisfactionRate(serviceWorkOrdersList);
|
||||
// 获取近半年工单柱状图数据
|
||||
// 获取近半年工单柱状图数据
|
||||
List<ServiceWorkOrderAnalysisVo.BarChartVo> recentSixMonthWorkOrders = getRecentSixMonthsWorkOrders(serviceWorkOrdersList);
|
||||
// 构建 VO 并返回
|
||||
return new ServiceWorkOrderAnalysisVo.ServiceWorkOrderCount()
|
||||
@@ -332,7 +332,9 @@ public class ServiceWorkOrdersServiceImpl implements IServiceWorkOrdersService {
|
||||
.setSatisfactionChartList(satisfactionChartList)
|
||||
.setRecentSixMonthWorkOrders(recentSixMonthWorkOrders)
|
||||
.build();
|
||||
} /**
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算满意度指数占比
|
||||
*
|
||||
* @return 满意度比例列表
|
||||
@@ -363,11 +365,12 @@ public class ServiceWorkOrdersServiceImpl implements IServiceWorkOrdersService {
|
||||
default -> "未知";
|
||||
};
|
||||
|
||||
satisfactionRateList.add(new ServiceWorkOrderAnalysisVo.SatisfactionChartVo(name,count,rate));
|
||||
satisfactionRateList.add(new ServiceWorkOrderAnalysisVo.SatisfactionChartVo(name, count, rate));
|
||||
}
|
||||
|
||||
return satisfactionRateList;
|
||||
}
|
||||
|
||||
// 近一周工单统计方法
|
||||
private List<ServiceWorkOrderAnalysisVo.LineChartVo> getRecentWeekWorkOrders(List<ServiceWorkOrders> serviceWorkOrdersList) {
|
||||
LocalDate today = LocalDate.now();
|
||||
@@ -419,10 +422,12 @@ public class ServiceWorkOrdersServiceImpl implements IServiceWorkOrdersService {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean isProcessed(ServiceWorkOrders order) {
|
||||
// 假设有一个字段 status 表示状态,"COMPLETED" 表示已处理
|
||||
return "4".equalsIgnoreCase(order.getStatus());
|
||||
}
|
||||
|
||||
// 计算工单类型分布
|
||||
private List<ServiceWorkOrderAnalysisVo.PieChartVo> calculateWorkOrderTypeDistribution(List<ServiceWorkOrders> serviceWorkOrdersList) {
|
||||
// 按 typeId 分组统计数量
|
||||
@@ -445,6 +450,7 @@ public class ServiceWorkOrdersServiceImpl implements IServiceWorkOrdersService {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<ServiceWorkOrderAnalysisVo.BarChartVo> getRecentSixMonthsWorkOrders(List<ServiceWorkOrders> ordersList) {
|
||||
LocalDate today = LocalDate.now();
|
||||
// 获取近6个月的日期范围(含当月)
|
||||
@@ -459,9 +465,9 @@ public class ServiceWorkOrdersServiceImpl implements IServiceWorkOrdersService {
|
||||
Collectors.counting()
|
||||
));
|
||||
|
||||
// 构建柱状图数据
|
||||
// 构建柱状图数据
|
||||
return months.stream()
|
||||
.map(month -> new ServiceWorkOrderAnalysisVo.BarChartVo(month,Math.toIntExact(orderCountMap.getOrDefault(month, 0L))))
|
||||
.map(month -> new ServiceWorkOrderAnalysisVo.BarChartVo(month, Math.toIntExact(orderCountMap.getOrDefault(month, 0L))))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package org.dromara.property.service.impl;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
@@ -92,6 +93,7 @@ public class ServiceWorkOrdersTypeServiceImpl implements IServiceWorkOrdersTypeS
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean insertByBo(ServiceWorkOrdersTypeBo bo) {
|
||||
ServiceWorkOrdersType add = MapstructUtils.convert(bo, ServiceWorkOrdersType.class);
|
||||
add.setOrderTypeNo("TD" + IdUtil.getSnowflakeNextIdStr());
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package org.dromara.property.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
@@ -76,22 +75,22 @@ public class TbCommunityServiceImpl implements ITbCommunityService {
|
||||
community.addAll(list);
|
||||
}
|
||||
}
|
||||
//if (level >= 4) {
|
||||
// List<TbUnitVo> vos = unitService.queryAll();
|
||||
// if (vos != null && !vos.isEmpty()) {
|
||||
// List<TreeNode<Long>> list = vos.stream().map(item -> {
|
||||
// TreeNode<Long> node = new TreeNode<>();
|
||||
// node.setChildren(new ArrayList<>());
|
||||
// node.setCode(item.getId());
|
||||
// node.setLabel(item.getUnitName());
|
||||
// node.setParentCode(item.getBuildingId());
|
||||
// node.setLevel(3);
|
||||
// return node;
|
||||
// }).toList();
|
||||
// community.addAll(list);
|
||||
// }
|
||||
//}
|
||||
if (level >= 3) {
|
||||
List<TbUnitVo> vos = unitService.queryAll();
|
||||
if (vos != null && !vos.isEmpty()) {
|
||||
List<TreeNode<Long>> list = vos.stream().map(item -> {
|
||||
TreeNode<Long> node = new TreeNode<>();
|
||||
node.setChildren(new ArrayList<>());
|
||||
node.setCode(item.getId());
|
||||
node.setLabel(item.getUnitName());
|
||||
node.setParentCode(item.getBuildingId());
|
||||
node.setLevel(3);
|
||||
return node;
|
||||
}).toList();
|
||||
community.addAll(list);
|
||||
}
|
||||
}
|
||||
if (level >= 4) {
|
||||
List<TbFloorVo> vos = floorService.queryAll();
|
||||
if (vos != null && !vos.isEmpty()) {
|
||||
List<TreeNode<Long>> list = vos.stream().map(item -> {
|
||||
@@ -99,15 +98,15 @@ public class TbCommunityServiceImpl implements ITbCommunityService {
|
||||
node.setChildren(new ArrayList<>());
|
||||
node.setCode(item.getId());
|
||||
node.setLabel(item.getFloorName());
|
||||
node.setParentCode(item.getUnitId());
|
||||
node.setLevel(4);
|
||||
node.setParentCode(item.getBuildingId());
|
||||
node.setLevel(3);
|
||||
return node;
|
||||
}).toList();
|
||||
community.addAll(list);
|
||||
}
|
||||
}
|
||||
|
||||
if (level >= 5) {
|
||||
if (level >= 4) {
|
||||
List<TbRoomVo> vos = roomService.queryAll();
|
||||
if (vos != null && !vos.isEmpty()) {
|
||||
List<TreeNode<Long>> list = vos.stream().map(item -> {
|
||||
@@ -116,7 +115,7 @@ public class TbCommunityServiceImpl implements ITbCommunityService {
|
||||
node.setCode(item.getId());
|
||||
node.setLabel(item.getRoomNumber());
|
||||
node.setParentCode(item.getFloorId());
|
||||
node.setLevel(5);
|
||||
node.setLevel(4);
|
||||
return node;
|
||||
}).toList();
|
||||
community.addAll(list);
|
||||
|
@@ -12,9 +12,10 @@ import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.property.domain.TbFloor;
|
||||
import org.dromara.property.domain.bo.TbFloorBo;
|
||||
import org.dromara.property.domain.vo.TbBuildingVo;
|
||||
import org.dromara.property.domain.vo.TbFloorVo;
|
||||
import org.dromara.property.domain.vo.TbUnitVo;
|
||||
import org.dromara.property.mapper.TbFloorMapper;
|
||||
import org.dromara.property.service.ITbBuildingService;
|
||||
import org.dromara.property.service.ITbFloorService;
|
||||
import org.dromara.property.service.ITbUnitService;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -37,6 +38,7 @@ public class TbFloorServiceImpl implements ITbFloorService {
|
||||
|
||||
private final TbFloorMapper baseMapper;
|
||||
private final ITbUnitService tbUnitService;
|
||||
private final ITbBuildingService iTbBuildingService;
|
||||
|
||||
/**
|
||||
* 查询楼层
|
||||
@@ -81,7 +83,7 @@ public class TbFloorServiceImpl implements ITbFloorService {
|
||||
lqw.orderByAsc(TbFloor::getId);
|
||||
lqw.like(StringUtils.isNotBlank(bo.getFloorName()), TbFloor::getFloorName, bo.getFloorName());
|
||||
lqw.eq(bo.getFloorNumber() != null, TbFloor::getFloorNumber, bo.getFloorNumber());
|
||||
lqw.eq(bo.getUnitId() != null, TbFloor::getUnitId, bo.getUnitId());
|
||||
lqw.eq(bo.getBuildingId()!= null, TbFloor::getUnitId, bo.getBuildingId());
|
||||
lqw.eq(bo.getFloorType() != null, TbFloor::getFloorType, bo.getFloorType());
|
||||
lqw.eq(bo.getRoomCount() != null, TbFloor::getRoomCount, bo.getRoomCount());
|
||||
lqw.eq(bo.getFloorHeight() != null, TbFloor::getFloorHeight, bo.getFloorHeight());
|
||||
@@ -98,19 +100,19 @@ public class TbFloorServiceImpl implements ITbFloorService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean insertByBo(TbFloorBo bo) {
|
||||
// 验证单元是否存在
|
||||
TbUnitVo tbUnitVo = tbUnitService.queryById(bo.getUnitId());
|
||||
Assert.notNull(tbUnitVo, "单元:{},不存在。", bo.getUnitId());
|
||||
TbBuildingVo tbBuildingVo = iTbBuildingService.queryById(bo.getBuildingId());
|
||||
Assert.notNull(tbBuildingVo, "建筑:{},不存在。", tbBuildingVo);
|
||||
|
||||
// 验证同一单元楼层是否已经存在
|
||||
LambdaQueryWrapper<TbFloor> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(TbFloor::getUnitId, bo.getUnitId())
|
||||
lqw.eq(TbFloor::getBuildingId, bo.getBuildingId())
|
||||
.eq(TbFloor::getFloorNumber, bo.getFloorNumber());
|
||||
boolean numberExists = baseMapper.selectCount(lqw) > 0;
|
||||
Assert.isFalse(numberExists, "单元:{},楼层:{}已存在。", bo.getUnitId(), bo.getFloorNumber());
|
||||
Assert.isFalse(numberExists, "单元:{},建筑:{}已存在。", bo.getBuildingId(), bo.getFloorNumber());
|
||||
|
||||
TbFloor add = MapstructUtils.convert(bo, TbFloor.class);
|
||||
add.setCommunityId(tbUnitVo.getCommunityId());
|
||||
add.setBuildingId(tbUnitVo.getBuildingId());
|
||||
add.setCommunityId(tbBuildingVo.getCommunityId());
|
||||
add.setBuildingId(tbBuildingVo.getId());
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
Assert.isTrue(flag, "新增楼层失败");
|
||||
|
@@ -83,13 +83,13 @@ public class SisAuthRecordController extends BaseController {
|
||||
/**
|
||||
* 修改授权记录
|
||||
*/
|
||||
@SaCheckPermission("sis:authRecord:edit")
|
||||
@Log(title = "授权记录", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SisAuthRecordBo bo) {
|
||||
return toAjax(sisAuthRecordService.updateByBo(bo));
|
||||
}
|
||||
// @SaCheckPermission("sis:authRecord:edit")
|
||||
// @Log(title = "授权记录", businessType = BusinessType.UPDATE)
|
||||
// @RepeatSubmit()
|
||||
// @PutMapping()
|
||||
// public R<Void> edit(@Validated(EditGroup.class) @RequestBody SisAuthRecordBo bo) {
|
||||
// return toAjax(sisAuthRecordService.updateByBo(bo));
|
||||
// }
|
||||
|
||||
/**
|
||||
* 删除授权记录
|
||||
|
@@ -15,6 +15,7 @@ import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.sis.domain.bo.SisDeviceManageBo;
|
||||
import org.dromara.sis.domain.vo.SisDeviceManageVo;
|
||||
@@ -78,8 +79,9 @@ public class SisDeviceManageController extends BaseController {
|
||||
@Log(title = "设备管理", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody SisDeviceManageBo bo) {
|
||||
return toAjax(sisDeviceManageService.insertByBo(bo));
|
||||
public R<Boolean> add(@Validated(AddGroup.class) @RequestBody SisDeviceManageBo bo) {
|
||||
bo.setTenantId(LoginHelper.getTenantId());
|
||||
return R.ok("设备添加成功", sisDeviceManageService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,6 +1,8 @@
|
||||
package org.dromara.sis.controller.zkmedia;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.crypto.digest.MD5;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.sis.domain.enums.FactoryNoEnum;
|
||||
@@ -48,8 +50,9 @@ public class ZKLmediaController {
|
||||
public R<AddStreamProxyResp> alarm(@RequestBody @Validated AddStreamProxy data) {
|
||||
StartStreamProxy proxy = new StartStreamProxy();
|
||||
proxy.setApp("realtime");
|
||||
String s = IdUtil.fastSimpleUUID();
|
||||
proxy.setStream(s);
|
||||
// 实时流不用每次都去拉流,流不存在的情况下在拉取
|
||||
String streanStr = data.getVideoIp() + "_" + data.getChannelId();
|
||||
proxy.setStream(SecureUtil.md5(streanStr));
|
||||
if (FactoryNoEnum.HIK.getCode().equals(data.getFactoryNo())) {
|
||||
proxy.setUrl(String.format(HIK_REALTIME_RTSP_TEMPLATE, data.getAccount(), data.getPwd(), data.getVideoIp(), data.getVideoPort(), data.getChannelId()));
|
||||
} else if (FactoryNoEnum.DAHUA.getCode().equals(data.getFactoryNo())) {
|
||||
|
@@ -74,6 +74,7 @@ public class ZkMediaHookController {
|
||||
@PostMapping(value = "/on_stream_not_found", produces = "application/json;charset=UTF-8")
|
||||
public HookResult onStreamNotFound(@RequestBody OnStreamNotFoundHookParam param) {
|
||||
log.info("[ZLM HOOK] 流未找到:{}->{}->{}/{}", param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream());
|
||||
log.info("params={}", JSONObject.toJSONString(param));
|
||||
return HookResult.SUCCESS();
|
||||
}
|
||||
|
||||
|
@@ -74,5 +74,33 @@ public class SisDeviceChannel extends TenantEntity {
|
||||
*/
|
||||
private String channelNo;
|
||||
|
||||
/**
|
||||
* nvr 设备厂商编号
|
||||
*/
|
||||
private String nvrFactoryNo;
|
||||
|
||||
/**
|
||||
* nvr设备ip
|
||||
*/
|
||||
private String nvrIp;
|
||||
|
||||
/**
|
||||
* nvr 端口
|
||||
*/
|
||||
private Integer nvrPort;
|
||||
|
||||
/**
|
||||
* nvr 账号
|
||||
*/
|
||||
private String nvrAccount;
|
||||
|
||||
/**
|
||||
* nvr 密码
|
||||
*/
|
||||
private String nvrPwd;
|
||||
|
||||
/**
|
||||
* nvr 通道编号
|
||||
*/
|
||||
private String nvrChannelNo;
|
||||
}
|
||||
|
@@ -78,4 +78,9 @@ public class SisPersonLibImg extends TenantEntity {
|
||||
*/
|
||||
private Long residentPersonId;
|
||||
|
||||
/**
|
||||
* 图片MD5
|
||||
*/
|
||||
private String imgMd5Value;
|
||||
|
||||
}
|
||||
|
@@ -1,13 +1,14 @@
|
||||
package org.dromara.sis.domain.bo;
|
||||
|
||||
import org.dromara.sis.domain.SisDeviceChannel;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import jakarta.validation.constraints.*;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.sis.domain.SisDeviceChannel;
|
||||
|
||||
/**
|
||||
* 设备通道管理业务对象 sis_device_channel
|
||||
@@ -23,13 +24,13 @@ public class SisDeviceChannelBo extends BaseEntity {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@NotNull(message = "主键id不能为空", groups = { EditGroup.class })
|
||||
@NotNull(message = "主键id不能为空", groups = {EditGroup.class})
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 设备id
|
||||
*/
|
||||
@NotNull(message = "设备id不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
@NotNull(message = "设备id不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private Long deviceId;
|
||||
|
||||
/**
|
||||
@@ -42,31 +43,31 @@ public class SisDeviceChannelBo extends BaseEntity {
|
||||
/**
|
||||
* 通道分组组id
|
||||
*/
|
||||
@NotNull(message = "通道分组组id不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
@NotNull(message = "通道分组组id不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private Long groupId;
|
||||
|
||||
/**
|
||||
* 设备ip
|
||||
*/
|
||||
@NotBlank(message = "设备ip不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
@NotBlank(message = "设备ip不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String deviceIp;
|
||||
|
||||
/**
|
||||
* 设备端口
|
||||
*/
|
||||
@NotNull(message = "设备端口不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
@NotNull(message = "设备端口不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private Integer devicePort;
|
||||
|
||||
/**
|
||||
* 设备账号
|
||||
*/
|
||||
@NotBlank(message = "设备账号不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
@NotBlank(message = "设备账号不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String deviceAccount;
|
||||
|
||||
/**
|
||||
* 设备密码
|
||||
*/
|
||||
@NotBlank(message = "设备密码不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
@NotBlank(message = "设备密码不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String devicePwd;
|
||||
|
||||
/**
|
||||
@@ -79,5 +80,36 @@ public class SisDeviceChannelBo extends BaseEntity {
|
||||
*/
|
||||
private String channelNo;
|
||||
|
||||
/**
|
||||
* nvr 设备厂商编号
|
||||
*/
|
||||
private String nvrFactoryNo;
|
||||
|
||||
/**
|
||||
* nvr设备ip
|
||||
*/
|
||||
private String nvrIp;
|
||||
|
||||
/**
|
||||
* nvr 端口
|
||||
*/
|
||||
private Integer nvrPort;
|
||||
|
||||
/**
|
||||
* nvr 账号
|
||||
*/
|
||||
private String nvrAccount;
|
||||
|
||||
/**
|
||||
* nvr 密码
|
||||
*/
|
||||
private String nvrPwd;
|
||||
|
||||
/**
|
||||
* nvr 通道编号
|
||||
*/
|
||||
private String nvrChannelNo;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -8,7 +8,6 @@ import lombok.EqualsAndHashCode;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
||||
import org.dromara.common.translation.annotation.Translation;
|
||||
import org.dromara.sis.domain.SisDeviceManage;
|
||||
|
||||
/**
|
||||
@@ -78,5 +77,6 @@ public class SisDeviceManageBo extends BaseEntity {
|
||||
*/
|
||||
private Long groupId;
|
||||
|
||||
private String tenantId;
|
||||
|
||||
}
|
||||
|
@@ -86,4 +86,9 @@ public class SisPersonLibImgBo extends BaseEntity {
|
||||
*/
|
||||
private Long residentPersonId;
|
||||
|
||||
/**
|
||||
* 图片MD5
|
||||
*/
|
||||
private String imgMd5Value;
|
||||
|
||||
}
|
||||
|
@@ -9,8 +9,8 @@ import lombok.Getter;
|
||||
@Getter
|
||||
public enum FactoryNoEnum {
|
||||
|
||||
HIK("DS1013"),
|
||||
DAHUA("DS1014");
|
||||
HIK("1"),
|
||||
DAHUA("2");
|
||||
|
||||
private final String code;
|
||||
|
||||
|
@@ -90,5 +90,33 @@ public class SisDeviceChannelVo implements Serializable {
|
||||
@ExcelProperty(value = "设备通道编号")
|
||||
private String channelNo;
|
||||
|
||||
/**
|
||||
* nvr 设备厂商编号
|
||||
*/
|
||||
private String nvrFactoryNo;
|
||||
|
||||
/**
|
||||
* nvr设备ip
|
||||
*/
|
||||
private String nvrIp;
|
||||
|
||||
/**
|
||||
* nvr 端口
|
||||
*/
|
||||
private Integer nvrPort;
|
||||
|
||||
/**
|
||||
* nvr 账号
|
||||
*/
|
||||
private String nvrAccount;
|
||||
|
||||
/**
|
||||
* nvr 密码
|
||||
*/
|
||||
private String nvrPwd;
|
||||
|
||||
/**
|
||||
* nvr 通道编号
|
||||
*/
|
||||
private String nvrChannelNo;
|
||||
}
|
||||
|
@@ -96,4 +96,10 @@ public class SisPersonLibImgVo implements Serializable {
|
||||
*/
|
||||
@ExcelProperty(value = "入驻员工id")
|
||||
private Long residentPersonId;
|
||||
|
||||
/**
|
||||
* 图片MD5
|
||||
*/
|
||||
@ExcelProperty(value = "图片MD5")
|
||||
private String imgMd5Value;
|
||||
}
|
||||
|
@@ -7,6 +7,8 @@ import org.dromara.sis.api.RemoteSisAuth;
|
||||
import org.dromara.sis.api.domain.RemotePersonAuth;
|
||||
import org.dromara.sis.service.ISisAuthRecordService;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author lsm
|
||||
* @apiNote RemoteSisAuthImpl
|
||||
@@ -23,4 +25,14 @@ public class RemoteSisAuthImpl implements RemoteSisAuth {
|
||||
public Boolean personAuth(RemotePersonAuth personAuth) {
|
||||
return sisAuthRecordService.insertByPerson(personAuth);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updatePersonAuth(RemotePersonAuth personAuth) {
|
||||
return sisAuthRecordService.updateByBo(personAuth);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deletePersonAuth(Collection<Long> ids, Collection<Long> e8Ids) {
|
||||
return sisAuthRecordService.deleteByPersonIds(ids, e8Ids);
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package org.dromara.sis.sdk.hik.model;
|
||||
|
||||
import lombok.Data;
|
||||
import org.dromara.sis.domain.enums.FactoryNoEnum;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -27,6 +28,8 @@ public class DeviceInfo {
|
||||
*/
|
||||
private Integer dwStartDChan;
|
||||
|
||||
private String factoryNo = FactoryNoEnum.HIK.getCode();
|
||||
|
||||
private List<DeviceChannelInfo> channelInfo;
|
||||
|
||||
@Data
|
||||
|
@@ -52,12 +52,12 @@ public interface ISisAuthRecordService {
|
||||
Boolean insertByPerson(RemotePersonAuth bo);
|
||||
|
||||
/**
|
||||
* 修改授权记录
|
||||
* 修改授权记录(单个)
|
||||
*
|
||||
* @param bo 授权记录
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
Boolean updateByBo(SisAuthRecordBo bo);
|
||||
Boolean updateByBo(RemotePersonAuth bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除授权记录信息
|
||||
@@ -105,4 +105,13 @@ public interface ISisAuthRecordService {
|
||||
* @return SisAuthRecordVo
|
||||
*/
|
||||
SisAuthRecordVo queryByGroupIdAndPersonId(Long groupId, Long personId);
|
||||
|
||||
/**
|
||||
* 批量删除授权记录
|
||||
*
|
||||
* @param ids 入驻员工ids
|
||||
* @param e8Ids e8id
|
||||
*/
|
||||
Boolean deleteByPersonIds(Collection<Long> ids, Collection<Long> e8Ids);
|
||||
|
||||
}
|
||||
|
@@ -7,6 +7,7 @@ import org.dromara.sis.domain.SisDeviceChannel;
|
||||
import org.dromara.sis.domain.bo.SisDeviceChannelBo;
|
||||
import org.dromara.sis.domain.bo.SisDeviceManageBo;
|
||||
import org.dromara.sis.domain.vo.SisDeviceChannelVo;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -85,13 +86,16 @@ public interface ISisDeviceChannelService {
|
||||
List<TreeNode<Long>> queryTree();
|
||||
|
||||
|
||||
Boolean handleHikDeviceChannel(SisDeviceManageBo bo);
|
||||
void handleHikDeviceChannel(SisDeviceManageBo bo);
|
||||
|
||||
/**
|
||||
* 通过设备ids 删除设备通道信息
|
||||
*
|
||||
* @param deviceIds 设备ids
|
||||
* @return 返回删除数量
|
||||
*/
|
||||
Integer deleteByDeviceIds(List<Long> deviceIds);
|
||||
|
||||
SisDeviceChannel queryByChannelIp(String channelIp);
|
||||
|
||||
}
|
||||
|
@@ -79,7 +79,23 @@ public interface ISisPersonLibImgService {
|
||||
*
|
||||
* @param personId 入驻员工id
|
||||
* @param huaweiBoxId 华为盒子图像id
|
||||
* @param imgMd5 图片md5值
|
||||
* @return Boolean
|
||||
*/
|
||||
Boolean updateByPersonId(Long personId, Long huaweiBoxId);
|
||||
Boolean updateByPersonId(Long personId, Long huaweiBoxId, String imgMd5);
|
||||
|
||||
|
||||
/**
|
||||
* 根据图片MD5,查询图片
|
||||
*
|
||||
* @param imgMd5 图片MD5
|
||||
*/
|
||||
SisPersonLibImgVo queryByImgMd5(String imgMd5);
|
||||
|
||||
/**
|
||||
* 根据入驻员工id,查询图片
|
||||
*
|
||||
* @param personId 入驻员工id
|
||||
*/
|
||||
SisPersonLibImgVo queryByPersonId(Long personId);
|
||||
}
|
||||
|
@@ -3,7 +3,6 @@ package org.dromara.sis.service.impl;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.dromara.common.core.domain.TreeNode;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -13,12 +12,15 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.property.api.RemoteFloorService;
|
||||
import org.dromara.property.api.domain.vo.RemoteFloorVo;
|
||||
import org.dromara.resource.api.RemoteFileService;
|
||||
import org.dromara.sis.api.domain.RemotePersonAuth;
|
||||
import org.dromara.sis.domain.bo.SisAccessControlBo;
|
||||
import org.dromara.sis.domain.bo.SisElevatorInfoBo;
|
||||
import org.dromara.sis.domain.bo.SisPersonLibImgBo;
|
||||
import org.dromara.sis.domain.vo.SisAccessControlVo;
|
||||
import org.dromara.sis.domain.vo.SisElevatorInfoVo;
|
||||
import org.dromara.sis.domain.vo.SisPersonLibImgVo;
|
||||
import org.dromara.sis.sdk.e8.E8PlatformApi;
|
||||
import org.dromara.sis.service.*;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.dromara.sis.domain.bo.SisAuthRecordBo;
|
||||
@@ -27,6 +29,7 @@ import org.dromara.sis.domain.SisAuthRecord;
|
||||
import org.dromara.sis.mapper.SisAuthRecordMapper;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -40,6 +43,8 @@ import java.util.*;
|
||||
@Service
|
||||
public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
|
||||
|
||||
private final E8PlatformApi e8PlatformApi;
|
||||
|
||||
private final SisAuthRecordMapper baseMapper;
|
||||
private final ISisElevatorInfoService elevatorInfoService;
|
||||
private final ISisPersonLibImgService sisPersonLibImgService;
|
||||
@@ -48,6 +53,9 @@ public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
|
||||
@DubboReference
|
||||
private RemoteFloorService remoteFloorService;
|
||||
|
||||
@DubboReference
|
||||
private RemoteFileService remoteFileService;
|
||||
|
||||
/**
|
||||
* 查询授权记录
|
||||
*
|
||||
@@ -112,30 +120,69 @@ public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
|
||||
add.setGroupId(bo.getAuthGroupId());
|
||||
add.setBegDate(bo.getAuthBegDate());
|
||||
add.setEndDate(bo.getAuthEndDate());
|
||||
add.setTenantId("000000");
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
Assert.isTrue(flag, "新增授权记录失败");
|
||||
|
||||
if (flag) {
|
||||
try {
|
||||
// 记录图片md5值
|
||||
byte[] imgByte = remoteFileService.downloadToByteArray(Long.parseLong(bo.getOssId()));
|
||||
String md5 = calculateMD5(imgByte);
|
||||
// 写入安防人像信息
|
||||
this.syncPersonImg(bo);
|
||||
this.syncPersonImg(bo, md5);
|
||||
} catch (Exception e) {
|
||||
log.info("下载图片失败");
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
private void syncPersonImg(RemotePersonAuth bo) {
|
||||
private void syncPersonImg(RemotePersonAuth bo, String md5) {
|
||||
log.info("开始写入安防人像信息");
|
||||
SisPersonLibImgBo personLibImg = new SisPersonLibImgBo();
|
||||
personLibImg.setImgOssId(Long.parseLong(bo.getOssId()));
|
||||
personLibImg.setTel(bo.getPhone());
|
||||
personLibImg.setImgName(bo.getName());
|
||||
personLibImg.setSex(bo.getSex());
|
||||
personLibImg.setCertificateType(1);
|
||||
personLibImg.setCertificateNo(bo.getIdCardNumber());
|
||||
personLibImg.setResidentPersonId(bo.getId());
|
||||
personLibImg.setImgMd5Value(md5);
|
||||
sisPersonLibImgService.insertByBo(personLibImg);
|
||||
log.info("写入安防人像信息完成");
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接计算字节数组的MD5值
|
||||
*
|
||||
* @param data 图片的字节数组
|
||||
* @return 32位小写MD5字符串
|
||||
*/
|
||||
private String calculateMD5(byte[] data) throws Exception {
|
||||
if (data == null) {
|
||||
throw new IllegalArgumentException("输入数据不能为null");
|
||||
}
|
||||
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
md.update(data);
|
||||
return bytesToHex(md.digest());
|
||||
}
|
||||
|
||||
/**
|
||||
* 字节数组转十六进制字符串
|
||||
*
|
||||
* @param bytes 字节数组
|
||||
* @return 32位十六进制字符串
|
||||
*/
|
||||
private String bytesToHex(byte[] bytes) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte b : bytes) {
|
||||
// %02x 表示两位小写十六进制,不足两位补0
|
||||
sb.append(String.format("%02x", b));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改授权记录
|
||||
*
|
||||
@@ -143,10 +190,25 @@ public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(SisAuthRecordBo bo) {
|
||||
SisAuthRecord update = MapstructUtils.convert(bo, SisAuthRecord.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean updateByBo(RemotePersonAuth bo) {
|
||||
LambdaQueryWrapper<SisAuthRecord> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(SisAuthRecord::getTargetId, bo.getId());
|
||||
boolean flag = baseMapper.delete(lqw) > 0;
|
||||
Assert.isTrue(flag, "删除授权记录失败");
|
||||
|
||||
// 删除人像库图片
|
||||
SisPersonLibImgVo imgVo = sisPersonLibImgService.queryByPersonId(bo.getId());
|
||||
if (imgVo != null) {
|
||||
flag = sisPersonLibImgService.deleteWithValidByIds(List.of(imgVo.getId()), false);
|
||||
Assert.isTrue(flag, "删除人像库图片失败");
|
||||
}
|
||||
|
||||
// 删除e8人员
|
||||
flag = e8PlatformApi.deleteCustomer(bo.getE8Id());
|
||||
Assert.isTrue(flag, "删除e8人员失败");
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -273,4 +335,36 @@ public class SisAuthRecordServiceImpl implements ISisAuthRecordService {
|
||||
.eq(SisAuthRecord::getTargetId, personId);
|
||||
return baseMapper.selectVoOne(lqw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除授权记录
|
||||
*
|
||||
* @param ids 入驻员工ids
|
||||
* @param e8Ids e8id
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean deleteByPersonIds(Collection<Long> ids, Collection<Long> e8Ids) {
|
||||
LambdaQueryWrapper<SisAuthRecord> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.in(SisAuthRecord::getTargetId, ids);
|
||||
boolean flag = baseMapper.delete(lqw) > 0;
|
||||
Assert.isTrue(flag, "删除授权记录失败");
|
||||
|
||||
if (flag) {
|
||||
|
||||
List<SisPersonLibImgVo> list = new ArrayList<>();
|
||||
ids.forEach(id -> {
|
||||
SisPersonLibImgVo imgVo = sisPersonLibImgService.queryByPersonId(id);
|
||||
if (imgVo != null) {
|
||||
list.add(imgVo);
|
||||
}
|
||||
});
|
||||
Collection<Long> imgIds = list.stream().map(SisPersonLibImgVo::getId).toList();
|
||||
flag = sisPersonLibImgService.deleteWithValidByIds(imgIds, false);
|
||||
Assert.isTrue(flag, "删除人像库图片失败");
|
||||
|
||||
e8Ids.forEach(e8PlatformApi::deleteCustomer);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package org.dromara.sis.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -24,6 +25,7 @@ import org.dromara.sis.sdk.hik.HikSdkConstans;
|
||||
import org.dromara.sis.sdk.hik.model.DeviceInfo;
|
||||
import org.dromara.sis.service.ISisDeviceChannelService;
|
||||
import org.dromara.sis.service.ISisDeviceGroupService;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -194,54 +196,98 @@ public class SisDeviceChannelServiceImpl implements ISisDeviceChannelService {
|
||||
return TreeUtils.build(treeNodes, -1L);
|
||||
}
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public Boolean handleHikDeviceChannel(SisDeviceManageBo bo) {
|
||||
public void handleHikDeviceChannel(SisDeviceManageBo bo) {
|
||||
// 调用hik sdk登录
|
||||
boolean isLogin = HikApiService.getInstance().login(bo.getDeviceIp(), bo.getDevicePort().shortValue(), bo.getDeviceAccount(), bo.getDevicePwd());
|
||||
if (!isLogin) {
|
||||
throw new RuntimeException("海康设备添加失败.");
|
||||
}
|
||||
if (DeviceTypeEnum.IPC.getType().equals(bo.getDeviceType())) {
|
||||
// 写入设备通道信息
|
||||
SisDeviceChannel channel = new SisDeviceChannel();
|
||||
channel.setDeviceId(bo.getId());
|
||||
channel.setChannelName(bo.getDeviceName());
|
||||
channel.setGroupId(bo.getGroupId());
|
||||
channel.setDeviceIp(bo.getDeviceIp());
|
||||
channel.setDevicePort(HikSdkConstans.DEFAULT_RTSP_PORT);
|
||||
channel.setFactoryNo(bo.getFactoryNo());
|
||||
channel.setDeviceAccount(bo.getDeviceAccount());
|
||||
channel.setDevicePwd(bo.getDevicePwd());
|
||||
channel.setDeviceMac(bo.getDeviceMac());
|
||||
channel.setChannelNo(HikSdkConstans.DEFAULT_CHANNEL);
|
||||
this.insert(channel);
|
||||
return true;
|
||||
// 校验设备通道是否存在,如果存在则放弃添加
|
||||
SisDeviceChannel channel1 = this.queryByChannelIp(bo.getDeviceIp());
|
||||
if (channel1 != null) {
|
||||
// 写入设备通道信息
|
||||
SisDeviceChannel channel = new SisDeviceChannel();
|
||||
channel.setDeviceId(bo.getId());
|
||||
channel.setChannelName(bo.getDeviceName());
|
||||
channel.setGroupId(bo.getGroupId());
|
||||
channel.setDeviceIp(bo.getDeviceIp());
|
||||
channel.setDevicePort(HikSdkConstans.DEFAULT_RTSP_PORT);
|
||||
channel.setFactoryNo(bo.getFactoryNo());
|
||||
channel.setDeviceAccount(bo.getDeviceAccount());
|
||||
channel.setDevicePwd(bo.getDevicePwd());
|
||||
channel.setDeviceMac(bo.getDeviceMac());
|
||||
channel.setChannelNo(HikSdkConstans.DEFAULT_CHANNEL);
|
||||
channel.setTenantId(bo.getTenantId());
|
||||
Boolean insert = this.insert(channel);
|
||||
log.info("设备[{}]通道添加完成,result={}", bo.getDeviceIp(), insert);
|
||||
} else {
|
||||
log.info("设备通道[{}]已存在,放弃添加通道信息", bo.getDeviceIp());
|
||||
}
|
||||
} else if (DeviceTypeEnum.NVR.getType().equals(bo.getDeviceType()) || DeviceTypeEnum.DVR.getType().equals(bo.getDeviceType())) {
|
||||
DeviceInfo channelInfo = HikApiService.getInstance().getChannelInfo(bo.getDeviceIp());
|
||||
if (channelInfo != null && CollUtil.isNotEmpty(channelInfo.getChannelInfo())) {
|
||||
List<SisDeviceChannel> channels = new ArrayList<>(channelInfo.getChannelInfo().size());
|
||||
List<SisDeviceChannel> insertChannels = new ArrayList<>(channelInfo.getChannelInfo().size());
|
||||
List<SisDeviceChannel> updateChannels = new ArrayList<>(channelInfo.getChannelInfo().size());
|
||||
channelInfo.getChannelInfo().forEach(item -> {
|
||||
SisDeviceChannel channel = new SisDeviceChannel();
|
||||
// 校验通道信息是否存在
|
||||
SisDeviceChannel channel = queryByChannelIp(item.getChannelIp());
|
||||
boolean isUpdate = true;
|
||||
if (channel == null) {
|
||||
channel = new SisDeviceChannel();
|
||||
isUpdate = false;
|
||||
}
|
||||
// 通道设备信息
|
||||
channel.setDeviceIp(item.getChannelIp());
|
||||
channel.setDevicePort(Integer.valueOf(item.getChannelPort()));
|
||||
channel.setDeviceAccount(item.getChannelAccount());
|
||||
channel.setFactoryNo(channelInfo.getFactoryNo());
|
||||
if (StrUtil.isNotEmpty(item.getChannelPwd())) {
|
||||
channel.setDevicePwd(item.getChannelPwd());
|
||||
}
|
||||
// nvr 设备信息
|
||||
channel.setNvrIp(bo.getDeviceIp());
|
||||
channel.setNvrPort(HikSdkConstans.DEFAULT_RTSP_PORT);
|
||||
channel.setNvrAccount(bo.getDeviceAccount());
|
||||
channel.setNvrPwd(bo.getDevicePwd());
|
||||
channel.setNvrFactoryNo(bo.getFactoryNo());
|
||||
channel.setNvrChannelNo(item.getChannelId() + HikSdkConstans.DEFAULT_CHANNEL_PREFX);
|
||||
|
||||
// 系统设备信息
|
||||
channel.setDeviceMac(bo.getDeviceMac());
|
||||
// 将设备id 更改为nvr的设备id
|
||||
channel.setDeviceId(bo.getId());
|
||||
channel.setGroupId(bo.getGroupId());
|
||||
channel.setDeviceIp(bo.getDeviceIp());
|
||||
channel.setDevicePort(HikSdkConstans.DEFAULT_RTSP_PORT);
|
||||
channel.setFactoryNo(bo.getFactoryNo());
|
||||
channel.setDeviceAccount(bo.getDeviceAccount());
|
||||
channel.setDevicePwd(bo.getDevicePwd());
|
||||
channel.setDeviceMac(bo.getDeviceMac());
|
||||
|
||||
channel.setChannelName(item.getChannelName());
|
||||
channel.setChannelNo(item.getChannelId() + HikSdkConstans.DEFAULT_CHANNEL_PREFX);
|
||||
channels.add(channel);
|
||||
channel.setTenantId(bo.getTenantId());
|
||||
if (isUpdate) {
|
||||
updateChannels.add(channel);
|
||||
} else {
|
||||
insertChannels.add(channel);
|
||||
}
|
||||
});
|
||||
this.baseMapper.insertBatch(channels);
|
||||
// 更新通道信息
|
||||
if (CollUtil.isNotEmpty(updateChannels)) {
|
||||
this.baseMapper.updateBatchById(updateChannels);
|
||||
}
|
||||
// 写入新的通道信息
|
||||
if (CollUtil.isNotEmpty(insertChannels)) {
|
||||
this.baseMapper.insertBatch(insertChannels);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
log.info("未知的设备类型,不处理。");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SisDeviceChannel queryByChannelIp(String channelIp) {
|
||||
LambdaQueryWrapper<SisDeviceChannel> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SisDeviceChannel::getDeviceIp, channelIp);
|
||||
return baseMapper.selectOne(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -250,4 +296,5 @@ public class SisDeviceChannelServiceImpl implements ISisDeviceChannelService {
|
||||
lqw.in(SisDeviceChannel::getDeviceId, deviceIds);
|
||||
return baseMapper.delete(lqw);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -23,6 +23,8 @@ import org.dromara.sis.service.ISisDeviceManageService;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -104,18 +106,13 @@ public class SisDeviceManageServiceImpl implements ISisDeviceManageService {
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
// 获取设备通道信息
|
||||
handleDeviceChannelInfo(bo);
|
||||
if (Objects.equals(bo.getFactoryNo(), FactoryNoEnum.HIK.getCode())) {
|
||||
deviceChannelService.handleHikDeviceChannel(bo);
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
public void handleDeviceChannelInfo(SisDeviceManageBo bo) {
|
||||
if (Objects.equals(bo.getFactoryNo(), FactoryNoEnum.HIK.getCode())) {
|
||||
deviceChannelService.handleHikDeviceChannel(bo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改设备管理
|
||||
*
|
||||
@@ -165,24 +162,16 @@ public class SisDeviceManageServiceImpl implements ISisDeviceManageService {
|
||||
*/
|
||||
@Async
|
||||
public void deleteDeviceRef(List<SisDeviceManage> sisDeviceManages) {
|
||||
List<Long> deviceIds = new ArrayList<>(sisDeviceManages.size());
|
||||
Map<String, List<SisDeviceManage>> factoryGroup = new HashMap<>(10);
|
||||
sisDeviceManages.forEach(sisDeviceManage -> {
|
||||
deviceIds.add(sisDeviceManage.getId());
|
||||
factoryGroup.computeIfAbsent(sisDeviceManage.getFactoryNo(), k -> new ArrayList<>()).add(sisDeviceManage);
|
||||
|
||||
List<Long> deviceIds = new ArrayList<>();
|
||||
sisDeviceManages.forEach(item -> {
|
||||
// 删除设备
|
||||
deviceIds.add(item.getId());
|
||||
if (FactoryNoEnum.HIK.getCode().equals(item.getFactoryNo())) {
|
||||
HikApiService.getInstance().loginOut(item.getDeviceIp());
|
||||
}
|
||||
});
|
||||
// 删除设备通道
|
||||
int num = deviceChannelService.deleteByDeviceIds(deviceIds);
|
||||
log.info("删除设备通道完成,num={}", num);
|
||||
// 设备sdk注销
|
||||
for (Map.Entry<String, List<SisDeviceManage>> entry : factoryGroup.entrySet()) {
|
||||
if (entry.getKey().equals(FactoryNoEnum.HIK.getCode())) {
|
||||
entry.getValue().forEach(item -> {
|
||||
HikApiService.getInstance().loginOut(item.getDeviceIp());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -118,6 +118,8 @@ public class SisPersonLibImgServiceImpl implements ISisPersonLibImgService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean insertByBo(SisPersonLibImgBo bo) {
|
||||
SisPersonLibImg add = MapstructUtils.convert(bo, SisPersonLibImg.class);
|
||||
assert add != null;
|
||||
add.setTenantId("000000");
|
||||
Assert.notNull(add, "数据处理失败");
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
Assert.isTrue(flag, "新增数据失败");
|
||||
@@ -165,7 +167,7 @@ public class SisPersonLibImgServiceImpl implements ISisPersonLibImgService {
|
||||
boolean flag = baseMapper.deleteByIds(ids) > 0;
|
||||
Assert.isTrue(flag, "删除失败");
|
||||
|
||||
return true;
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -182,16 +184,47 @@ public class SisPersonLibImgServiceImpl implements ISisPersonLibImgService {
|
||||
/**
|
||||
* 根据入驻员工id,更新huaweiBoxId
|
||||
*
|
||||
* @param personId 入驻员工id
|
||||
* @param personId 入驻员工id
|
||||
* @param huaweiBoxId 华为盒子图像id
|
||||
* @param imgMd5 图片md5值
|
||||
* @return Boolean
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByPersonId(Long personId, Long huaweiBoxId){
|
||||
public Boolean updateByPersonId(Long personId, Long huaweiBoxId, String imgMd5) {
|
||||
LambdaQueryWrapper<SisPersonLibImg> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(SisPersonLibImg::getResidentPersonId, personId);
|
||||
SisPersonLibImg update = new SisPersonLibImg();
|
||||
update.setRemoteImgId(huaweiBoxId);
|
||||
update.setImgMd5Value(imgMd5);
|
||||
return baseMapper.update(update, lqw) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据图片MD5,查询图片
|
||||
*
|
||||
* @param imgMd5 图片MD5
|
||||
*/
|
||||
@Override
|
||||
public SisPersonLibImgVo queryByImgMd5(String imgMd5) {
|
||||
LambdaQueryWrapper<SisPersonLibImg> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(SisPersonLibImg::getImgMd5Value, imgMd5);
|
||||
List<SisPersonLibImgVo> list = baseMapper.selectVoList(lqw);
|
||||
if (list.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
return list.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据入驻员工id,查询图片
|
||||
*
|
||||
* @param personId 入驻员工id
|
||||
*/
|
||||
@Override
|
||||
public SisPersonLibImgVo queryByPersonId(Long personId) {
|
||||
LambdaQueryWrapper<SisPersonLibImg> lqw = new LambdaQueryWrapper<>();
|
||||
lqw.eq(SisPersonLibImg::getResidentPersonId, personId);
|
||||
return baseMapper.selectVoOne(lqw);
|
||||
}
|
||||
}
|
||||
|
@@ -30,6 +30,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
@@ -68,7 +69,7 @@ public class AuthSyncTask {
|
||||
// 需要先设置模拟上下文
|
||||
SaTokenContextMockUtil.setMockContext(() -> {
|
||||
// 模拟登录
|
||||
StpUtil.login(1); // 模拟登录
|
||||
StpUtil.login(1);
|
||||
unAuthPersonRef.set(remoteResidentPersonService.queryUnAuthPerson());
|
||||
List<RemoteResidentPersonVo> unAuthPerson = unAuthPersonRef.get();
|
||||
|
||||
@@ -89,12 +90,25 @@ public class AuthSyncTask {
|
||||
byte[] imgByte = imgByteRef.get();
|
||||
if (imgByte == null) continue;
|
||||
|
||||
// 写入华为盒子
|
||||
Long huaweiId = syncHuaweiBox(person, imgByte);
|
||||
String nowMd5 = this.calculateMD5(imgByte);
|
||||
SisPersonLibImgVo imgVo = sisPersonLibImgService.queryByImgMd5(nowMd5);
|
||||
|
||||
Long huaweiId;
|
||||
Boolean update;
|
||||
if (ObjectUtil.isEmpty(imgVo)) {
|
||||
// 写入华为盒子
|
||||
huaweiId = syncHuaweiBox(person, imgByte);
|
||||
} else {
|
||||
if (imgVo.getRemoteImgId() == null) {
|
||||
huaweiId = syncHuaweiBox(person, imgByte);
|
||||
} else {
|
||||
huaweiId = imgVo.getRemoteImgId();
|
||||
}
|
||||
}
|
||||
if (huaweiId == null) continue;
|
||||
|
||||
// 更新人像信息huaweiBoxId
|
||||
Boolean update = sisPersonLibImgService.updateByPersonId(person.getId(), huaweiId);
|
||||
update = sisPersonLibImgService.updateByPersonId(person.getId(), huaweiId, nowMd5);
|
||||
if (!update) continue;
|
||||
|
||||
// 同步E8平台
|
||||
@@ -105,7 +119,6 @@ public class AuthSyncTask {
|
||||
remoteResidentPersonService.updateE8Id(person.getId(), e8Id);
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
log.info("无待授权人员");
|
||||
}
|
||||
@@ -115,12 +128,18 @@ public class AuthSyncTask {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 补录授权记录
|
||||
*
|
||||
* @param person bean
|
||||
*/
|
||||
private void syncAuthRecord(RemoteResidentPersonVo person) {
|
||||
log.info("开始补录授权记录、人像信息");
|
||||
RemotePersonAuth personAuth = new RemotePersonAuth();
|
||||
personAuth.setId(person.getId());
|
||||
personAuth.setOssId(person.getOssId());
|
||||
personAuth.setName(person.getName());
|
||||
personAuth.setPhone(person.getPhone());
|
||||
personAuth.setSex(person.getGender().intValue());
|
||||
personAuth.setIdCardNumber(person.getIdCard());
|
||||
personAuth.setAuthGroupId(person.getAuthGroupId());
|
||||
@@ -130,6 +149,13 @@ public class AuthSyncTask {
|
||||
log.info("补录授权记录、人像信息完成");
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步华为盒子
|
||||
*
|
||||
* @param vo bean
|
||||
* @param imgByte 图片字节
|
||||
* @return Long
|
||||
*/
|
||||
private Long syncHuaweiBox(RemoteResidentPersonVo vo, byte[] imgByte) {
|
||||
log.info("开始写入华为平台");
|
||||
AddHWPersonReq req = new AddHWPersonReq();
|
||||
@@ -149,6 +175,13 @@ public class AuthSyncTask {
|
||||
return pId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步E8平台
|
||||
*
|
||||
* @param vo bean
|
||||
* @param imgByte 图片字节
|
||||
* @return Long
|
||||
*/
|
||||
private Long syncE8Plat(RemoteResidentPersonVo vo, byte[] imgByte) {
|
||||
|
||||
log.info("e8平台上传照片");
|
||||
@@ -205,4 +238,35 @@ public class AuthSyncTask {
|
||||
}
|
||||
return e8Id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接计算字节数组的MD5值
|
||||
*
|
||||
* @param data 图片的字节数组
|
||||
* @return 32位小写MD5字符串
|
||||
*/
|
||||
public String calculateMD5(byte[] data) throws Exception {
|
||||
if (data == null) {
|
||||
throw new IllegalArgumentException("输入数据不能为null");
|
||||
}
|
||||
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
md.update(data);
|
||||
return bytesToHex(md.digest());
|
||||
}
|
||||
|
||||
/**
|
||||
* 字节数组转十六进制字符串
|
||||
*
|
||||
* @param bytes 字节数组
|
||||
* @return 32位十六进制字符串
|
||||
*/
|
||||
private String bytesToHex(byte[] bytes) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte b : bytes) {
|
||||
// %02x 表示两位小写十六进制,不足两位补0
|
||||
sb.append(String.format("%02x", b));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="checkAuth" resultType="org.dromara.sis.domain.vo.SisAuthRecordVo">
|
||||
SELECT c.target_id, c.group_id, c.beg_date, c.end_date
|
||||
FROM sis_person_lib_img a
|
||||
LEFT JOIN resident_person b ON a.resident_person_id = b.id
|
||||
LEFT JOIN resident_person b ON a.resident_person_id = b.id and b.state = 1
|
||||
LEFT JOIN sis_auth_record c
|
||||
ON c.target_id = b.id
|
||||
AND c.group_id = b.auth_group_id
|
||||
|
@@ -83,6 +83,14 @@ public class RemoteUserServiceImpl implements RemoteUserService {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public RemoteUserVo getUserInfoById(Long userId) throws UserException {
|
||||
SysUserVo sysUser = userMapper.selectVoById(userId);
|
||||
// 框架登录不限制从什么表查询 只要最终构建出 LoginUser 即可
|
||||
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
|
||||
return BeanUtil.copyProperties(sysUser,RemoteUserVo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户id查询用户信息
|
||||
*
|
||||
|
Reference in New Issue
Block a user