creat:硬件列表
This commit is contained in:
1 parent
b789b302e7
commit
a4c12ee30c
21 files changed
+372
-156
No files matched your search
@@ -38,5 +38,15 @@
|
||||
<groupId>com.bsd</groupId>
|
||||
<artifactId>pjcloud-common-excel</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.bsd</groupId>
|
||||
<artifactId>pjcloud-upms-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.bsd</groupId>
|
||||
<artifactId>pjcloud-wallet-api</artifactId>
|
||||
<version>5.7.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.bsd.pjcloud.hard.api.constant;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 硬件设备类型
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum HardTypeEnum {
|
||||
|
||||
SUPERMARKET(1, "超市"),
|
||||
CANTEEN(2, "食堂"),
|
||||
READ_CARD(3, "读卡器"),
|
||||
DOOR(4, "生鲜柜"),
|
||||
;
|
||||
private final Integer type;
|
||||
private final String description;
|
||||
|
||||
public static HardTypeEnum valueOfByType(Integer type) {
|
||||
if (ObjectUtil.isEmpty(type)) return null;
|
||||
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get();
|
||||
}
|
||||
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.bsd.pjcloud.hard.api.constant.mq;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* mq action
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum MqActionEnum {
|
||||
SYNC_CONFIG("同步设置"),
|
||||
SYNC_PRODUCT("同步菜单"),
|
||||
SYNC_CLASSIFY("同步分类"),
|
||||
PRINT("打印"),
|
||||
USER_FACE_CHANGE("用户人脸变化"),
|
||||
;
|
||||
private final String description;
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.bsd.pjcloud.hard.api.constant;
|
||||
package com.bsd.pjcloud.hard.api.constant.order;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.bsd.pjcloud.hard.api.constant;
|
||||
package com.bsd.pjcloud.hard.api.constant.order;
|
||||
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
+4
-2
@@ -3,8 +3,7 @@ package com.bsd.pjcloud.hard.api.entity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.*;
|
||||
import com.bsd.pjcloud.common.core.util.TenantTable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@@ -14,6 +13,9 @@ import java.time.LocalDateTime;
|
||||
* @author dzc
|
||||
* @date 2025-01-05 14:16:52
|
||||
*/
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@TenantTable
|
||||
@TableName("hard_manager")
|
||||
|
||||
+9
-1
@@ -1,8 +1,16 @@
|
||||
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.wallet.api.vo.base.BaseMchInterface;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class HardManagerVo extends HardManagerEntity {
|
||||
public class HardManagerVo extends HardManagerEntity implements BaseDeptInterface, BaseMchInterface {
|
||||
|
||||
|
||||
private String deptName;
|
||||
|
||||
private String merchantName;
|
||||
|
||||
}
|
||||
@@ -94,6 +94,12 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.bsd</groupId>
|
||||
<artifactId>pjcloud-wallet-api</artifactId>
|
||||
<version>5.7.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<profiles>
|
||||
<profile>
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.bsd.pjcloud.hard.common.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Data
|
||||
@ConfigurationProperties(prefix = "mqtt")
|
||||
@Component
|
||||
public class MqttConfig {
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* 连接地址
|
||||
*/
|
||||
private String hostUrl;
|
||||
/**
|
||||
* clientId
|
||||
*/
|
||||
private String clientId;
|
||||
/**
|
||||
* 安卓连接地址
|
||||
*/
|
||||
private String androidAddress;
|
||||
/**
|
||||
* 安卓连接端口
|
||||
*/
|
||||
private String androidPort;
|
||||
}
|
||||
+27
-53
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardInvoiceDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.HardInvoiceEntity;
|
||||
import com.bsd.pjcloud.hard.service.HardInvoiceService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -29,90 +30,63 @@ import java.util.List;
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/hard-invoice" )
|
||||
@Tag(description = "hard-invoice" , name = "发票记录管理" )
|
||||
@RequestMapping("/hard-invoice")
|
||||
@Tag(description = "hard-invoice", name = "发票记录管理")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class HardInvoiceController {
|
||||
|
||||
private final HardInvoiceService hardInvoiceService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page 分页对象
|
||||
* @param hardInvoice 发票记录
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "分页查询" , description = "分页查询" )
|
||||
@GetMapping("/page" )
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardInvoice_view')" )
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardInvoice_view')")
|
||||
public R getHardInvoicePage(@ParameterObject Page page, @ParameterObject HardInvoiceEntity hardInvoice) {
|
||||
LambdaQueryWrapper<HardInvoiceEntity> wrapper = Wrappers.lambdaQuery();
|
||||
return R.ok(hardInvoiceService.page(page, wrapper));
|
||||
}
|
||||
|
||||
@Operation(summary = "分页复杂查询", description = "分页复杂查询")
|
||||
@GetMapping("/page-join")
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardInvoice_view')")
|
||||
public R pageJoin(@ParameterObject Page page, @ParameterObject HardInvoiceDto dto) {
|
||||
return R.ok(hardInvoiceService.pageJoin(page, dto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询发票记录
|
||||
* @param id id
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id查询" , description = "通过id查询" )
|
||||
@GetMapping("/{id}" )
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardInvoice_view')" )
|
||||
public R getById(@PathVariable("id" ) Long id) {
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardInvoice_view')")
|
||||
public R getById(@PathVariable("id") Long id) {
|
||||
return R.ok(hardInvoiceService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增发票记录
|
||||
* @param hardInvoice 发票记录
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "新增发票记录" , description = "新增发票记录" )
|
||||
@SysLog("新增发票记录" )
|
||||
@Operation(summary = "新增发票记录", description = "新增发票记录")
|
||||
@SysLog("新增发票记录")
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardInvoice_add')" )
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardInvoice_add')")
|
||||
public R save(@RequestBody HardInvoiceEntity hardInvoice) {
|
||||
return R.ok(hardInvoiceService.save(hardInvoice));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改发票记录
|
||||
* @param hardInvoice 发票记录
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "修改发票记录" , description = "修改发票记录" )
|
||||
@SysLog("修改发票记录" )
|
||||
@Operation(summary = "修改发票记录", description = "修改发票记录")
|
||||
@SysLog("修改发票记录")
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardInvoice_edit')" )
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardInvoice_edit')")
|
||||
public R updateById(@RequestBody HardInvoiceEntity hardInvoice) {
|
||||
return R.ok(hardInvoiceService.updateById(hardInvoice));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除发票记录
|
||||
* @param ids id列表
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id删除发票记录" , description = "通过id删除发票记录" )
|
||||
@SysLog("通过id删除发票记录" )
|
||||
@Operation(summary = "通过id删除发票记录", description = "通过id删除发票记录")
|
||||
@SysLog("通过id删除发票记录")
|
||||
@DeleteMapping
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardInvoice_del')" )
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardInvoice_del')")
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
return R.ok(hardInvoiceService.removeBatchByIds(CollUtil.toList(ids)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出excel 表格
|
||||
* @param hardInvoice 查询条件
|
||||
* @param ids 导出指定ID
|
||||
* @return excel 文件流
|
||||
*/
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardInvoice_export')" )
|
||||
public List<HardInvoiceEntity> export(HardInvoiceEntity hardInvoice,Long[] ids) {
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardInvoice_export')")
|
||||
public List<HardInvoiceEntity> export(HardInvoiceEntity hardInvoice, Long[] ids) {
|
||||
return hardInvoiceService.list(Wrappers.lambdaQuery(hardInvoice).in(ArrayUtil.isNotEmpty(ids), HardInvoiceEntity::getId, ids));
|
||||
}
|
||||
}
|
||||
+13
-37
@@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardInvoiceDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardManagerDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.HardManagerEntity;
|
||||
import com.bsd.pjcloud.hard.service.HardManagerService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -36,12 +38,6 @@ public class HardManagerController {
|
||||
|
||||
private final HardManagerService hardManagerService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page 分页对象
|
||||
* @param hardManager 设备管理
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "分页查询" , description = "分页查询" )
|
||||
@GetMapping("/page" )
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardManager_view')" )
|
||||
@@ -50,12 +46,13 @@ public class HardManagerController {
|
||||
return R.ok(hardManagerService.page(page, wrapper));
|
||||
}
|
||||
|
||||
@Operation(summary = "分页复杂查询", description = "分页复杂查询")
|
||||
@GetMapping("/page-join")
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardInvoice_view')")
|
||||
public R pageJoin(@ParameterObject Page page, @ParameterObject HardManagerDto dto) {
|
||||
return R.ok(hardManagerService.pageJoin(page, dto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询设备管理
|
||||
* @param id id
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id查询" , description = "通过id查询" )
|
||||
@GetMapping("/{id}" )
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardManager_view')" )
|
||||
@@ -63,37 +60,23 @@ public class HardManagerController {
|
||||
return R.ok(hardManagerService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增设备管理
|
||||
* @param hardManager 设备管理
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "新增设备管理" , description = "新增设备管理" )
|
||||
@SysLog("新增设备管理" )
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardManager_add')" )
|
||||
public R save(@RequestBody HardManagerEntity hardManager) {
|
||||
return R.ok(hardManagerService.save(hardManager));
|
||||
public R save(@RequestBody HardManagerDto dto) {
|
||||
return R.ok(hardManagerService.create(dto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设备管理
|
||||
* @param hardManager 设备管理
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "修改设备管理" , description = "修改设备管理" )
|
||||
@SysLog("修改设备管理" )
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardManager_edit')" )
|
||||
public R updateById(@RequestBody HardManagerEntity hardManager) {
|
||||
return R.ok(hardManagerService.updateById(hardManager));
|
||||
public R updateById(@RequestBody HardManagerDto dto) {
|
||||
hardManagerService.edit(dto);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除设备管理
|
||||
* @param ids id列表
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id删除设备管理" , description = "通过id删除设备管理" )
|
||||
@SysLog("通过id删除设备管理" )
|
||||
@DeleteMapping
|
||||
@@ -102,13 +85,6 @@ public class HardManagerController {
|
||||
return R.ok(hardManagerService.removeBatchByIds(CollUtil.toList(ids)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出excel 表格
|
||||
* @param hardManager 查询条件
|
||||
* @param ids 导出指定ID
|
||||
* @return excel 文件流
|
||||
*/
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('hard_hardManager_export')" )
|
||||
|
||||
+11
-2
@@ -1,11 +1,20 @@
|
||||
package com.bsd.pjcloud.hard.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardInvoiceDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.HardInvoiceEntity;
|
||||
import com.bsd.pjcloud.hard.api.vo.HardInvoiceVo;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface HardInvoiceMapper extends PjcloudBaseMapper<HardInvoiceEntity> {
|
||||
|
||||
|
||||
default Page<HardInvoiceVo> pageJoin(Page page, HardInvoiceDto dto) {
|
||||
MPJLambdaWrapper<HardInvoiceEntity> wrapper = new MPJLambdaWrapper<HardInvoiceEntity>()
|
||||
.selectAll(HardInvoiceEntity.class)
|
||||
.eqIfExists(HardInvoiceEntity::getHardId, dto.getHardId())
|
||||
.eqIfExists(HardInvoiceEntity::getHardOrderId, dto.getHardOrderId());
|
||||
return selectJoinPage(page, HardInvoiceVo.class, wrapper);
|
||||
}
|
||||
}
|
||||
+11
-1
@@ -1,11 +1,21 @@
|
||||
package com.bsd.pjcloud.hard.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardManagerDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.HardManagerEntity;
|
||||
import com.bsd.pjcloud.hard.api.vo.HardManagerVo;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface HardManagerMapper extends PjcloudBaseMapper<HardManagerEntity> {
|
||||
|
||||
|
||||
default Page<HardManagerVo> pageJoin(Page page, HardManagerDto dto) {
|
||||
MPJLambdaWrapper<HardManagerEntity> wrapper = new MPJLambdaWrapper<HardManagerEntity>()
|
||||
.selectAll(HardManagerEntity.class)
|
||||
.eqIfExists(HardManagerEntity::getName, dto.getName())
|
||||
.eqIfExists(HardManagerEntity::getMerchantId, dto.getMerchantId());
|
||||
return selectJoinPage(page, HardManagerVo.class, wrapper);
|
||||
}
|
||||
}
|
||||
+4
@@ -1,8 +1,12 @@
|
||||
package com.bsd.pjcloud.hard.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardInvoiceDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.HardInvoiceEntity;
|
||||
import com.bsd.pjcloud.hard.api.vo.HardInvoiceVo;
|
||||
|
||||
public interface HardInvoiceService extends IService<HardInvoiceEntity> {
|
||||
|
||||
Page<HardInvoiceVo> pageJoin(Page page, HardInvoiceDto dto);
|
||||
}
|
||||
+9
@@ -1,8 +1,17 @@
|
||||
package com.bsd.pjcloud.hard.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardManagerDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.HardManagerEntity;
|
||||
import com.bsd.pjcloud.hard.api.vo.HardManagerVo;
|
||||
|
||||
public interface HardManagerService extends IService<HardManagerEntity> {
|
||||
|
||||
Page<HardManagerVo> pageJoin(Page page, HardManagerDto dto);
|
||||
|
||||
Long create(HardManagerDto dto);
|
||||
|
||||
void edit(HardManagerDto dto);
|
||||
|
||||
}
|
||||
+8
@@ -1,7 +1,10 @@
|
||||
package com.bsd.pjcloud.hard.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardInvoiceDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.HardInvoiceEntity;
|
||||
import com.bsd.pjcloud.hard.api.vo.HardInvoiceVo;
|
||||
import com.bsd.pjcloud.hard.mapper.HardInvoiceMapper;
|
||||
import com.bsd.pjcloud.hard.service.HardInvoiceService;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -15,4 +18,9 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class HardInvoiceServiceImpl extends ServiceImpl<HardInvoiceMapper, HardInvoiceEntity> implements HardInvoiceService {
|
||||
|
||||
@Override
|
||||
public Page<HardInvoiceVo> pageJoin(Page page, HardInvoiceDto dto) {
|
||||
Page<HardInvoiceVo> list = baseMapper.pageJoin(page, dto);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
+101
@@ -1,10 +1,35 @@
|
||||
package com.bsd.pjcloud.hard.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.admin.api.entity.SysDept;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteDeptService;
|
||||
import com.bsd.pjcloud.admin.api.utils.DataUtil;
|
||||
import com.bsd.pjcloud.common.core.util.CollectionUtils;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.hard.api.dto.HardManagerDto;
|
||||
import com.bsd.pjcloud.hard.api.entity.HardManagerEntity;
|
||||
import com.bsd.pjcloud.hard.api.vo.HardManagerVo;
|
||||
import com.bsd.pjcloud.hard.mapper.HardManagerMapper;
|
||||
import com.bsd.pjcloud.hard.service.HardManagerService;
|
||||
import com.bsd.pjcloud.hard.common.config.MqttConfig;
|
||||
import com.bsd.pjcloud.hard.utils.MqTopicUtil;
|
||||
import com.bsd.pjcloud.wallet.api.dto.MchManageDto;
|
||||
import com.bsd.pjcloud.wallet.api.feign.RemoteMchService;
|
||||
import com.bsd.pjcloud.wallet.api.utils.MchDataUtil;
|
||||
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletActiveVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 设备管理
|
||||
@@ -12,6 +37,82 @@ import org.springframework.stereotype.Service;
|
||||
* @author dzc
|
||||
* @date 2025-01-05 14:16:52
|
||||
*/
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class HardManagerServiceImpl extends ServiceImpl<HardManagerMapper, HardManagerEntity> implements HardManagerService {
|
||||
|
||||
private final MqttConfig mqttConfig;
|
||||
|
||||
private final RemoteMchService mchService;
|
||||
private final RemoteDeptService deptService;
|
||||
|
||||
@Override
|
||||
public Page<HardManagerVo> pageJoin(Page page, HardManagerDto dto) {
|
||||
Page<HardManagerVo> list = baseMapper.pageJoin(page, dto);
|
||||
if (ObjectUtil.isNotEmpty(list.getRecords())) {
|
||||
// 部门
|
||||
List<Long> deptIds = list.getRecords().stream().map(HardManagerVo::getDeptId).distinct().toList();
|
||||
R<Map<Long, SysDept>> deptList = deptService.getDeptByDeptIds(deptIds);
|
||||
if (ObjectUtil.isNotEmpty(deptList.getData())) {
|
||||
DataUtil.convertDeptList(list.getRecords(), deptList.getData());
|
||||
}
|
||||
// 商户
|
||||
List<Long> mchIds = list.getRecords().stream().map(HardManagerVo::getMerchantId).distinct().toList();
|
||||
R<List<MchManageVo>> mchList = mchService.getByIds(mchIds);
|
||||
if (ObjectUtil.isNotEmpty(mchList.getData())) {
|
||||
MchDataUtil.convertMchList(list.getRecords(), CollectionUtils.convertMap(mchList.getData(), MchManageVo::getId));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long create(HardManagerDto dto) {
|
||||
R<MchManageVo> mch = mchService.getById(dto.getMerchantId());
|
||||
Long deptId = Optional.of(mch).map(R::getData).map(MchManageVo::getDeptId).orElseThrow(() -> new RuntimeException("商户不存在"));
|
||||
dto.setDeptId(deptId);
|
||||
// mq地址和端口
|
||||
dto.setMqSocketAddress(mqttConfig.getAndroidAddress());
|
||||
dto.setMqSocketPort(mqttConfig.getAndroidPort());
|
||||
// 插入
|
||||
baseMapper.insert(dto);
|
||||
// topic
|
||||
HardManagerEntity updateObj = HardManagerEntity.builder().id(dto.getId()).build();
|
||||
String topic = createMqConfigByAction(dto.getDeptId(), null, 1) + "/#";
|
||||
updateObj.setMainTopic(topic);
|
||||
// client id
|
||||
String clientId = createMqConfigByAction(dto.getDeptId(), dto.getId(), 2);
|
||||
updateObj.setMqClientId(clientId);
|
||||
// username TODO 密码9位随机数字加字母
|
||||
String mqUsername = createMqConfigByAction(dto.getDeptId(), dto.getId(), 3);
|
||||
updateObj.setMqUsername(mqUsername);
|
||||
updateObj.setMqPassword(RandomUtil.randomString(9));
|
||||
baseMapper.updateById(updateObj);
|
||||
return dto.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void edit(HardManagerDto dto) {
|
||||
HardManagerEntity detail = baseMapper.selectById(dto.getId());
|
||||
if (ObjectUtil.isEmpty(detail)) {
|
||||
throw new RuntimeException("设备不存在");
|
||||
}
|
||||
baseMapper.updateById(dto);
|
||||
}
|
||||
|
||||
private String createMqConfigByAction(Long deptId, Long hardId, Integer action) {
|
||||
MqTopicUtil eventDto = MqTopicUtil.builder().deptId(deptId).hardId(hardId).build();
|
||||
if (ObjectUtil.equals(action, 1)) {
|
||||
return eventDto.getTopic();
|
||||
}
|
||||
if (ObjectUtil.equals(action, 2)) {
|
||||
return eventDto.getClientId();
|
||||
}
|
||||
if (ObjectUtil.equals(action, 3)) {
|
||||
return eventDto.getUsername();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
package com.bsd.pjcloud.hard.utils;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class MqTopicUtil {
|
||||
/**
|
||||
* 商户id
|
||||
*/
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 硬件id
|
||||
*/
|
||||
private Long hardId;
|
||||
|
||||
public String getTopic() {
|
||||
if (ObjectUtil.isAllNotEmpty(deptId, hardId)) {
|
||||
return String.format("topic/android/%s/%s", deptId, hardId);
|
||||
}
|
||||
if (ObjectUtil.isAllNotEmpty(deptId)) {
|
||||
return String.format("topic/android/%s", deptId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getClientId() {
|
||||
if (ObjectUtil.isAllNotEmpty(deptId, hardId)) {
|
||||
return String.format("client_id/android/%s/%s", deptId, hardId);
|
||||
}
|
||||
if (ObjectUtil.isAllNotEmpty(deptId)) {
|
||||
return String.format("client_id/android/%s", deptId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
if (ObjectUtil.isAllNotEmpty(deptId, hardId)) {
|
||||
return String.format("username_android_/android/%s/%s", deptId, hardId);
|
||||
}
|
||||
if (ObjectUtil.isAllNotEmpty(deptId)) {
|
||||
return String.format("username_android_/android/%s", deptId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+8
-6
@@ -3,8 +3,6 @@ package com.bsd.pjcloud.wallet.api.feign;
|
||||
import com.bsd.pjcloud.common.core.constant.ServiceNameConstants;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.feign.annotation.NoToken;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletTypeCodeEnum;
|
||||
import com.bsd.pjcloud.wallet.api.dto.MchManageDto;
|
||||
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -16,19 +14,23 @@ import java.util.List;
|
||||
public interface RemoteMchService {
|
||||
|
||||
@NoToken
|
||||
@GetMapping("/get-by-id")
|
||||
@GetMapping("/mch-manage/get-by-id")
|
||||
R<MchManageVo> getById(@RequestParam Long id);
|
||||
|
||||
@NoToken
|
||||
@GetMapping("/get-by-ids")
|
||||
@GetMapping("/mch-manage/get-by-ids")
|
||||
R<List<MchManageVo>> getByIds(@RequestParam List<Long> ids);
|
||||
|
||||
@NoToken
|
||||
@GetMapping("/get-by-dept-id")
|
||||
@GetMapping("/mch-manage/get-by-dept-id")
|
||||
R<MchManageVo> getByDeptId(@RequestParam Long deptId);
|
||||
|
||||
@NoToken
|
||||
@GetMapping("/get-first-mch")
|
||||
@GetMapping("/mch-manage/get-by-dept-ids")
|
||||
R<List<MchManageVo>> getByDeptIds(@RequestParam List<Long> deptIds);
|
||||
|
||||
@NoToken
|
||||
@GetMapping("/mch-manage/get-first-mch")
|
||||
R<MchManageVo> getFirstMch(@RequestParam List<Long> deptIds);
|
||||
|
||||
}
|
||||
+11
-50
@@ -40,7 +40,7 @@ import java.util.List;
|
||||
public class MchManageController {
|
||||
|
||||
private final MchManageService mchManageService;
|
||||
|
||||
|
||||
/* ************************************* start 远程调用 start ************************************* */
|
||||
|
||||
@Inner
|
||||
@@ -54,8 +54,8 @@ public class MchManageController {
|
||||
@Inner
|
||||
@GetMapping("/get-by-ids")
|
||||
public R<List<MchManageVo>> getByIds(@RequestParam List<Long> ids) {
|
||||
List<MchManageVo> list = mchManageService.list(MchManageDto.builder().deptIds(ids).build());
|
||||
if (ObjectUtil.isAllNotEmpty(list)) return R.failed("商户不存在");
|
||||
List<MchManageVo> list = mchManageService.list(MchManageDto.builder().ids(ids).build());
|
||||
if (ObjectUtil.isEmpty(list)) return R.failed("商户不存在");
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
@@ -67,6 +67,14 @@ public class MchManageController {
|
||||
return R.ok(mchManage);
|
||||
}
|
||||
|
||||
@Inner
|
||||
@GetMapping("/get-by-dept-ids")
|
||||
public R<List<MchManageVo>> getByDeptIds(@RequestParam List<Long> deptIds) {
|
||||
List<MchManageVo> list = mchManageService.list(MchManageDto.builder().deptIds(deptIds).build());
|
||||
if (ObjectUtil.isEmpty(list)) return R.failed("商户不存在");
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
@Inner
|
||||
@GetMapping("/get-first-mch")
|
||||
public R<MchManageVo> getFirstMch(@RequestParam List<Long> deptIds) {
|
||||
@@ -77,13 +85,6 @@ public class MchManageController {
|
||||
|
||||
/* ************************************* end 远程调用 end ************************************* */
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param mchManage 商户管理
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@pms.hasPermission('wallet_mchManage_view')")
|
||||
@@ -92,13 +93,6 @@ public class MchManageController {
|
||||
return R.ok(mchManageService.page(page, wrapper));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页复杂查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param dto 商户管理
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "分页复杂查询", description = "分页查询")
|
||||
@GetMapping("/page-join")
|
||||
@PreAuthorize("@pms.hasPermission('wallet_mchManage_view')")
|
||||
@@ -106,13 +100,6 @@ public class MchManageController {
|
||||
return R.ok(mchManageService.pageJoin(page, dto));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过id查询商户管理
|
||||
*
|
||||
* @param id id
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('wallet_mchManage_view')")
|
||||
@@ -120,12 +107,6 @@ public class MchManageController {
|
||||
return R.ok(mchManageService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增商户管理
|
||||
*
|
||||
* @param mchManage 商户管理
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "新增商户管理", description = "新增商户管理")
|
||||
@SysLog("新增商户管理")
|
||||
@PostMapping
|
||||
@@ -134,12 +115,6 @@ public class MchManageController {
|
||||
return R.ok(mchManageService.create(mchManage));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改商户管理
|
||||
*
|
||||
* @param mchManage 商户管理
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "修改商户管理", description = "修改商户管理")
|
||||
@SysLog("修改商户管理")
|
||||
@PutMapping
|
||||
@@ -149,12 +124,6 @@ public class MchManageController {
|
||||
return R.ok(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除商户管理
|
||||
*
|
||||
* @param ids id列表
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id删除商户管理", description = "通过id删除商户管理")
|
||||
@SysLog("通过id删除商户管理")
|
||||
@DeleteMapping
|
||||
@@ -164,14 +133,6 @@ public class MchManageController {
|
||||
return R.ok(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出excel 表格
|
||||
*
|
||||
* @param mchManage 查询条件
|
||||
* @param ids 导出指定ID
|
||||
* @return excel 文件流
|
||||
*/
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('wallet_mchManage_export')")
|
||||
|
||||
+2
-2
@@ -18,8 +18,8 @@ import com.bsd.pjcloud.wallet.api.entity.WalletCodeUseEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletCodeUseVo;
|
||||
import com.bsd.pjcloud.wallet.mapper.WalletCodeUseMapper;
|
||||
import com.bsd.pjcloud.wallet.service.WalletCodeUseService;
|
||||
import com.bsd.pjcloud.hard.api.constant.HardOrderTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.HardPayTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardPayTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.code.QRCodeDto;
|
||||
import com.bsd.pjcloud.hard.api.utils.HardUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
Reference in new issue
Block a user