feat:硬件分组查询
This commit is contained in:
1 parent
4dfd2bcc75
commit
ac830c925e
11 files changed
+76
-7
No files matched your search
@@ -9,7 +9,7 @@ CREATE TABLE hard_manager
|
||||
(
|
||||
id bigint NOT NULL COMMENT '编号',
|
||||
merchant_id bigint COMMENT '商户id',
|
||||
group_id bigint COMMENT '分组id',
|
||||
hard_group_id bigint COMMENT '分组id',
|
||||
dept_id bigint COMMENT '商家部门id',
|
||||
name varchar(128) NOT NULL COMMENT '设备名',
|
||||
type char(10) NOT NULL COMMENT '设备类型',
|
||||
|
||||
+4
@@ -3,7 +3,11 @@ package com.bsd.pjcloud.hard.api.dto;
|
||||
import com.bsd.pjcloud.hard.api.entity.HardGroupEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class HardGroupDto extends HardGroupEntity {
|
||||
|
||||
private List<Long> ids;
|
||||
|
||||
}
|
||||
+6
@@ -31,6 +31,12 @@ public class HardManagerEntity extends Model<HardManagerEntity> {
|
||||
@Schema(description="编号")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 分组id
|
||||
*/
|
||||
@Schema(description="分组id")
|
||||
private Long hardGroupId;
|
||||
|
||||
/**
|
||||
* 商户id
|
||||
*/
|
||||
|
||||
+13
@@ -5,8 +5,10 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.bsd.pjcloud.common.core.util.CollectionUtils;
|
||||
import com.bsd.pjcloud.hard.api.dto.code.QRCodeDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.HardGroupEntity;
|
||||
import com.bsd.pjcloud.hard.api.entity.HardManagerEntity;
|
||||
import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
|
||||
import com.bsd.pjcloud.hard.api.vo.base.BaseHardGroupInterface;
|
||||
import com.bsd.pjcloud.hard.api.vo.base.BaseHardInterface;
|
||||
import com.bsd.pjcloud.hard.api.vo.base.BaseOrderInterface;
|
||||
import lombok.experimental.UtilityClass;
|
||||
@@ -79,4 +81,15 @@ public class HardUtil {
|
||||
return v;
|
||||
}
|
||||
|
||||
public <T extends BaseHardGroupInterface> List<T> convertHardGroupList(List<T> list, Map<Long, HardGroupEntity> map) {
|
||||
return CollectionUtils.convertList(list, v -> convertHardGroup(v, map.get(v.getHardGroupId())));
|
||||
}
|
||||
|
||||
public <T extends BaseHardGroupInterface> T convertHardGroup(T v, HardGroupEntity entity) {
|
||||
if (ObjectUtil.isEmpty(entity)) return v;
|
||||
v.setHardGroupId(entity.getId());
|
||||
v.setHardGroupName(entity.getName());
|
||||
return v;
|
||||
}
|
||||
|
||||
}
|
||||
+9
-1
@@ -2,11 +2,12 @@ package com.bsd.pjcloud.hard.api.vo;
|
||||
|
||||
import com.bsd.pjcloud.admin.api.vo.base.BaseDeptInterface;
|
||||
import com.bsd.pjcloud.hard.api.entity.HardManagerEntity;
|
||||
import com.bsd.pjcloud.hard.api.vo.base.BaseHardGroupInterface;
|
||||
import com.bsd.pjcloud.wallet.api.vo.base.BaseMchInterface;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class HardManagerVo extends HardManagerEntity implements BaseDeptInterface, BaseMchInterface {
|
||||
public class HardManagerVo extends HardManagerEntity implements BaseDeptInterface, BaseMchInterface, BaseHardGroupInterface {
|
||||
|
||||
/**
|
||||
* android重点使用
|
||||
@@ -19,4 +20,11 @@ public class HardManagerVo extends HardManagerEntity implements BaseDeptInterfac
|
||||
|
||||
private String logoPic;
|
||||
|
||||
/**
|
||||
* 分类相关
|
||||
*/
|
||||
private Long hardGroupId;
|
||||
|
||||
private String hardGroupName;
|
||||
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.bsd.pjcloud.hard.api.vo.base;
|
||||
|
||||
public interface BaseHardGroupInterface {
|
||||
|
||||
Long getHardGroupId();
|
||||
|
||||
void setHardGroupId(Long hardGroupId);
|
||||
|
||||
String getHardGroupName();
|
||||
|
||||
void setHardGroupName(String hardGroupName);
|
||||
|
||||
}
|
||||
+8
@@ -12,6 +12,8 @@ import com.bsd.pjcloud.hard.api.vo.HardGroupVo;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface HardGroupMapper extends PjcloudBaseMapper<HardGroupEntity> {
|
||||
|
||||
@@ -29,4 +31,10 @@ public interface HardGroupMapper extends PjcloudBaseMapper<HardGroupEntity> {
|
||||
return list;
|
||||
}
|
||||
|
||||
default List<HardGroupEntity> list(HardGroupDto dto) {
|
||||
LambdaQueryWrapper<HardGroupEntity> wrapper = new LambdaQueryWrapper<HardGroupEntity>()
|
||||
.like(ObjectUtil.isNotEmpty(dto.getName()), HardGroupEntity::getName, dto.getName())
|
||||
.in(ObjectUtil.isNotEmpty(dto.getIds()), HardGroupEntity::getId, dto.getIds());
|
||||
return selectList(wrapper);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -38,7 +38,7 @@ public class HardGroupServiceImpl extends ServiceImpl<HardGroupMapper, HardGroup
|
||||
@Override
|
||||
public Page<HardGroupVo> pageJoin(Page page, HardGroupDto dto) {
|
||||
Page<HardGroupVo> list = baseMapper.pageJoin(page, dto);
|
||||
if (ObjectUtil.isNotEmpty(list)) {
|
||||
if (ObjectUtil.isNotEmpty(list.getRecords())) {
|
||||
// 部门
|
||||
List<Long> deptIds = list.getRecords().stream().map(HardGroupVo::getDeptId).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(deptIds)) {
|
||||
@@ -54,7 +54,7 @@ public class HardGroupServiceImpl extends ServiceImpl<HardGroupMapper, HardGroup
|
||||
@Override
|
||||
public Page<HardGroupVo> scopePageList(Page page, HardGroupDto dto) {
|
||||
Page<HardGroupVo> list = baseMapper.scopePageList(page, dto);
|
||||
if (ObjectUtil.isNotEmpty(list)) {
|
||||
if (ObjectUtil.isNotEmpty(list.getRecords())) {
|
||||
// 部门
|
||||
List<Long> deptIds = list.getRecords().stream().map(HardGroupVo::getDeptId).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(deptIds)) {
|
||||
|
||||
+17
@@ -11,11 +11,16 @@ import com.bsd.pjcloud.common.core.util.BeanUtils;
|
||||
import com.bsd.pjcloud.common.core.util.CollectionUtils;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.security.service.PjcloudUser;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardGroupDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardManagerDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.hard.HardBindDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.HardGroupEntity;
|
||||
import com.bsd.pjcloud.hard.api.entity.HardManagerEntity;
|
||||
import com.bsd.pjcloud.hard.api.utils.HardUtil;
|
||||
import com.bsd.pjcloud.hard.api.vo.HardManagerVo;
|
||||
import com.bsd.pjcloud.hard.mapper.HardGroupMapper;
|
||||
import com.bsd.pjcloud.hard.mapper.HardManagerMapper;
|
||||
import com.bsd.pjcloud.hard.service.HardGroupService;
|
||||
import com.bsd.pjcloud.hard.service.HardManagerService;
|
||||
import com.bsd.pjcloud.hard.mqtt.config.MqttConfig;
|
||||
import com.bsd.pjcloud.hard.utils.MqTopicUtil;
|
||||
@@ -46,6 +51,8 @@ public class HardManagerServiceImpl extends ServiceImpl<HardManagerMapper, HardM
|
||||
|
||||
private final MqttConfig mqttConfig;
|
||||
|
||||
private final HardGroupMapper hardGroupMapper;
|
||||
|
||||
private final RemoteMchService mchService;
|
||||
private final RemoteDeptService deptService;
|
||||
private final RemoteMqttEventService remoteMqttEventService;
|
||||
@@ -94,6 +101,16 @@ public class HardManagerServiceImpl extends ServiceImpl<HardManagerMapper, HardM
|
||||
WalletDataUtil.convertMchList(list.getRecords(), CollectionUtils.convertMap(mchList.getData(), MchManageVo::getId));
|
||||
}
|
||||
}
|
||||
// 分组
|
||||
List<Long> groupIds = list.getRecords().stream().map(HardManagerVo::getHardGroupId).distinct().toList();
|
||||
if (ObjectUtil.isNotEmpty(groupIds)) {
|
||||
HardGroupDto groupDto = new HardGroupDto();
|
||||
groupDto.setIds(groupIds);
|
||||
List<HardGroupEntity> groupList = hardGroupMapper.list(groupDto);
|
||||
if (ObjectUtil.isNotEmpty(groupList)) {
|
||||
HardUtil.convertHardGroupList(list.getRecords(), CollectionUtils.convertMap(groupList, HardGroupEntity::getId));
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
+1
-1
@@ -115,7 +115,7 @@ public class MchManageController {
|
||||
@Operation(summary = "分页不要权限下拉", description = "分页不要权限下拉")
|
||||
@GetMapping("/select")
|
||||
public R getSelect(@ParameterObject Page page, @ParameterObject MchManageDto dto) {
|
||||
return R.ok(mchManageService.pageJoin(page, dto));
|
||||
return R.ok(mchManageService.scopePageList(page, dto));
|
||||
}
|
||||
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
|
||||
+2
-2
@@ -126,7 +126,7 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
|
||||
if (ObjectUtil.isNotEmpty(deptIds)) {
|
||||
R<Map<Long, SysDept>> deptList = remoteDeptService.getDeptByDeptIds(deptIds);
|
||||
if (ObjectUtil.isNotEmpty(deptList.getData())) {
|
||||
DataUtil.convertDeptList(page.getRecords(), deptList.getData());
|
||||
DataUtil.convertDeptList(list.getRecords(), deptList.getData());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -142,7 +142,7 @@ public class MchManageServiceImpl extends ServiceImpl<MchManageMapper, MchManage
|
||||
if (ObjectUtil.isNotEmpty(deptIds)) {
|
||||
R<Map<Long, SysDept>> deptList = remoteDeptService.getDeptByDeptIds(deptIds);
|
||||
if (ObjectUtil.isNotEmpty(deptList.getData())) {
|
||||
DataUtil.convertDeptList(page.getRecords(), deptList.getData());
|
||||
DataUtil.convertDeptList(list.getRecords(), deptList.getData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user