Merge remote-tracking branch 'origin/master'

This commit is contained in:
zjf committed 2025-04-22 12:24:53 +08:00
commit 437e169e54
75 files changed
+1811 -343

No files matched your search

+45 -18
View File
@@ -367,30 +367,52 @@ CREATE TABLE hard_broadcast
PRIMARY KEY (id)
) ENGINE = InnoDB COMMENT ='设备广播';
DROP TABLE IF EXISTS hard_appt;
CREATE TABLE hard_appt
(
id bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
title varchar(64) NOT NULL COMMENT '标题',
start_time time DEFAULT NULL COMMENT '开始时间',
end_time time DEFAULT NULL COMMENT '结束时间',
sort int DEFAULT 0 NOT NULL COMMENT '排序',
status varchar(32) NOT NULL COMMENT '状态',
remark varchar(256) DEFAULT NULL COMMENT '备注',
create_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
create_time datetime DEFAULT NULL COMMENT '创建时间',
update_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人',
update_time datetime DEFAULT NULL COMMENT '修改时间',
del_flag char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记',
tenant_id bigint DEFAULT NULL COMMENT '租户ID',
PRIMARY KEY (id)
) ENGINE = InnoDB COMMENT ='设备预约管理';
-- ----------------------------
-- Table structure for hard_auth
-- ----------------------------
DROP TABLE IF EXISTS hard_auth;
CREATE TABLE hard_auth
(
id bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
auth_type varchar(32) DEFAULT NULL COMMENT '授权类型如微信小程序、支付宝、浙政钉',
user_id bigint NOT NULL COMMENT '预定用户',
hard_id bigint NOT NULL COMMENT '硬件id',
cabinet_no int DEFAULT NULL COMMENT '货柜编号',
auth_status char(1) DEFAULT '0' COMMENT '是否授权',
auth_time datetime DEFAULT NULL COMMENT '授权时间',
is_done char(1) DEFAULT '0' COMMENT '是否完成',
is_done_time datetime DEFAULT NULL COMMENT '完成时间',
is_manual_change varchar(32) DEFAULT NULL COMMENT '是否人工处理',
manual_change_time datetime DEFAULT NULL COMMENT '人工处理时间',
manual_change_remark varchar(512) DEFAULT NULL COMMENT '人工处理备注',
create_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
create_time datetime DEFAULT NULL COMMENT '创建时间',
update_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人',
update_time datetime DEFAULT NULL COMMENT '修改时间',
del_flag char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记',
tenant_id bigint DEFAULT NULL COMMENT '租户ID',
id bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
auth_type varchar(32) DEFAULT NULL COMMENT '授权类型如微信小程序、支付宝、浙政钉',
user_id bigint NOT NULL COMMENT '预定用户',
hard_id bigint NOT NULL COMMENT '硬件id',
cabinet_no int DEFAULT NULL COMMENT '货柜编号',
auth_status char(1) DEFAULT '0' COMMENT '是否授权',
auth_time datetime DEFAULT NULL COMMENT '授权时间',
is_done char(1) DEFAULT '0' COMMENT '是否完成',
is_done_time datetime DEFAULT NULL COMMENT '完成时间',
is_manual_change varchar(32) DEFAULT NULL COMMENT '是否人工处理',
manual_change_user_id bigint DEFAULT NULL COMMENT '人工处理用户id',
manual_change_time datetime DEFAULT NULL COMMENT '人工处理时间',
manual_change_remark varchar(128) DEFAULT NULL COMMENT '人工处理备注',
manual_change_pic varchar(512) DEFAULT NULL COMMENT '人工处理图片',
create_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
create_time datetime DEFAULT NULL COMMENT '创建时间',
update_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人',
update_time datetime DEFAULT NULL COMMENT '修改时间',
del_flag char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记',
tenant_id bigint DEFAULT NULL COMMENT '租户ID',
PRIMARY KEY (id)
) ENGINE = InnoDB COMMENT ='硬件授权';
@@ -444,6 +466,9 @@ CREATE TABLE hard_spu_join
cabinet_no varchar(32) DEFAULT NULL COMMENT '货柜编号',
spu_id bigint DEFAULT NULL COMMENT '商品id',
hard_door_number int DEFAULT NULL COMMENT '商品放置层数',
version bigint DEFAULT 0 COMMENT '乐观锁',
sales_count bigint DEFAULT 0 COMMENT '销量',
repertory_count bigint NOT NULL DEFAULT 0 COMMENT '库存',
create_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
create_time datetime DEFAULT NULL COMMENT '创建时间',
update_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人',
@@ -481,6 +506,8 @@ CREATE TABLE hard_spu_repertory
(
id bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
user_id bigint NOT NULL COMMENT '用户id',
hard_door_id bigint NOT NULL COMMENT '智能柜编号',
cabinet_no int NOT NULL COMMENT '货柜编号(1,2)',
spu_id bigint NOT NULL COMMENT '商品id',
before_count int NOT NULL COMMENT '更新前的库存数量',
count int DEFAULT 0 COMMENT '更新库存数量',
+30
View File
@@ -1,5 +1,35 @@
create database `pjcloudx_wallet` default character set utf8mb4 collate utf8mb4_general_ci;
-- ----------------------------
-- Table structure for sys_user_transaction
-- ----------------------------
DROP TABLE IF EXISTS sys_user_transaction;
CREATE TABLE `sys_user_transaction`
(
id bigint NOT NULL COMMENT '编号',
user_id bigint NOT NULL COMMENT '用户id',
biz_id bigint DEFAULT NULL COMMENT '业务id',
biz_type varchar(32) NOT NULL COMMENT '业务类型',
# 岗位调动字段
source_dept_id bigint DEFAULT NULL COMMENT '源部门id',
target_dept_id bigint DEFAULT NULL COMMENT '目标部门id',
# 离职字段
is_wallet_transaction varchar(32) DEFAULT NULL COMMENT '是否离职自动转账',
wallet_transaction_time datetime DEFAULT NULL COMMENT '离职自动转账时间',
# 审批字读
process_id varchar(256) DEFAULT NULL COMMENT '流程id',
process_status varchar(10) DEFAULT NULL COMMENT '审核状体',
process_time datetime DEFAULT NULL COMMENT '审核时间',
create_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
create_time datetime DEFAULT NULL COMMENT '创建时间',
update_by varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人',
update_time datetime DEFAULT NULL COMMENT '修改时间',
del_flag char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记',
tenant_id bigint DEFAULT NULL COMMENT '租户ID',
PRIMARY KEY (id)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_general_ci COMMENT ='人员调动表';
-- ----------------------------
-- Table structure for sys_user_face
@@ -32,4 +32,7 @@ public interface CommonRoleConstant {
// 商户角色
String MCH_USER = "MCH_USER";
// 智能柜管理员
String HARD_DOOR_ADMIN_USER = "HARD_DOOR_ADMIN";
}
@@ -19,7 +19,7 @@ public enum HardOrderStatusEnum {
OFFLINE_PAY("6", "没有网络本地支付"),
REFUND("10", "退款"),
CANCEL("20", "已核销"),
UNFOLLOW("30", "已取消(智能柜使用)"),
UNFOLLOW("30", "已取消(智能柜)"),
;
private final String type;
private final String description;
@@ -0,0 +1,8 @@
package com.bsd.pjcloud.hard.api.dto;
import com.bsd.pjcloud.hard.api.entity.HardApptEntity;
import lombok.Data;
@Data
public class HardApptDto extends HardApptEntity {
}
@@ -0,0 +1,27 @@
package com.bsd.pjcloud.hard.api.dto;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
@Data
public class HardAuthErrorChangeDto {
/**
* 流程id
*/
@NotNull(message = "流程id不能为空")
private Long flowId;
/**
* 处理图片
*/
private String image;
/**
* 处理原因
*/
@NotEmpty(message = "请输入处理原因")
private String remark;
}
@@ -0,0 +1,8 @@
package com.bsd.pjcloud.hard.api.dto.manager;
import com.bsd.pjcloud.hard.api.entity.manager.HardDoorCabinetEntity;
import lombok.Data;
@Data
public class HardDoorCabinetDto extends HardDoorCabinetEntity {
}
@@ -13,4 +13,6 @@ public class HardSpuRepertoryDto extends HardSpuRepertoryEntity {
private List<Long> userIds;
private Long cabinetId;
}
@@ -0,0 +1,108 @@
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 com.bsd.pjcloud.common.core.util.TenantTable;
import java.time.LocalDateTime;
import java.time.LocalTime;
/**
* 设备预约管理
*/
@Data
@TenantTable
@TableName("hard_appt")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "设备预约管理")
public class HardApptEntity extends Model<HardApptEntity> {
/**
* 编号
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description = "编号")
private Long id;
/**
* 标题
*/
@Schema(description = "标题")
private String title;
/**
* 开始时间
*/
@Schema(description = "开始时间")
private LocalTime startTime;
/**
* 结束时间
*/
@Schema(description = "结束时间")
private LocalTime endTime;
/**
* 排序
*/
@Schema(description = "排序")
private Integer sort;
/**
* 状态
*/
@Schema(description = "状态")
private String status;
/**
* 备注
*/
@Schema(description = "备注")
private String remark;
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description = "创建人")
private String createBy;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description = "创建时间")
private LocalDateTime createTime;
/**
* 修改人
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description = "修改人")
private String updateBy;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description = "修改时间")
private LocalDateTime updateTime;
/**
* 删除标记
*/
@TableLogic
@TableField(fill = FieldFill.INSERT)
@Schema(description = "删除标记")
private String delFlag;
/**
* 租户ID
*/
@Schema(description = "租户ID")
private Long tenantId;
}
@@ -83,6 +83,12 @@ public class HardAuthEntity extends Model<HardAuthEntity> {
@Schema(description = "是否人工处理")
private String isManualChange;
/**
* 人工处理用户id
*/
@Schema(description = "人工处理用户id")
private Long manualChangeUserId;
/**
* 人工处理时间
*/
@@ -92,9 +98,15 @@ public class HardAuthEntity extends Model<HardAuthEntity> {
/**
* 人工处理备注
*/
@Schema(description = "人工处理时间")
@Schema(description = "人工处理备注")
private String manualChangeRemark;
/**
* 人工处理图片
*/
@Schema(description = "人工处理图片")
private String manualChangePic;
/**
* 创建人
*/
@@ -23,10 +23,10 @@ public class HardBroadcastEntity extends Model<HardBroadcastEntity> {
/**
* 编号
* 广播编号
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description = "编号")
@Schema(description = "广播编号")
private Long id;
/**
@@ -51,6 +51,25 @@ public class HardSpuJoinEntity extends Model<HardSpuJoinEntity> {
@Schema(description = "放置层数")
private Integer hardDoorNumber;
/**
* 乐观锁
*/
@Version
private Integer version;
/**
* 销量
*/
@Schema(description = "销量")
private Integer salesCount;
/**
* 库存
*/
@Schema(description = "库存")
private Integer repertoryCount;
/**
* 创建人
*/
@@ -36,6 +36,19 @@ public class HardSpuRepertoryEntity extends Model<HardSpuRepertoryEntity> {
@Schema(description = "用户id")
private Long userId;
/**
* 硬件柜子id
*/
@Schema(description = "硬件柜子id")
private Long hardDoorId;
/**
* 柜门编号
*/
@Schema(description = "柜门编号")
private Integer cabinetNo;
/**
* 商品id
*/
@@ -0,0 +1,8 @@
package com.bsd.pjcloud.hard.api.vo;
import com.bsd.pjcloud.hard.api.entity.HardApptEntity;
import lombok.Data;
@Data
public class HardApptVo extends HardApptEntity {
}
@@ -1,6 +1,7 @@
package com.bsd.pjcloud.hard.api.vo;
import com.bsd.pjcloud.admin.api.vo.base.BaseUserDeptInterface;
import com.bsd.pjcloud.hard.api.entity.HardAuthEntity;
import com.bsd.pjcloud.hard.api.entity.HardDoorFlowEntity;
import com.bsd.pjcloud.hard.api.vo.base.BaseHardInterface;
import lombok.Data;
@@ -32,5 +33,7 @@ public class HardDoorFlowVo extends HardDoorFlowEntity implements BaseHardInterf
private String userDeptName;
private HardAuthEntity hardAuth;
}
@@ -0,0 +1,23 @@
package com.bsd.pjcloud.hard.api.vo.manager;
import com.bsd.pjcloud.hard.api.entity.manager.HardDoorCabinetEntity;
import com.bsd.pjcloud.hard.api.vo.base.BaseHardInterface;
import lombok.Data;
import java.util.List;
@Data
public class HardDoorCabinetVo extends HardDoorCabinetEntity implements BaseHardInterface {
/**
* 设备相关
*/
private Long hardId;
private String hardName;
private String hardType;
private String deviceCode;
}
@@ -2,11 +2,12 @@ package com.bsd.pjcloud.hard.api.vo.spu;
import com.bsd.pjcloud.admin.api.vo.base.BaseUserInterface;
import com.bsd.pjcloud.hard.api.entity.spu.HardSpuRepertoryEntity;
import com.bsd.pjcloud.hard.api.vo.base.BaseHardInterface;
import com.bsd.pjcloud.wallet.api.vo.base.BaseMchInterface;
import lombok.Data;
@Data
public class HardSpuRepertoryVo extends HardSpuRepertoryEntity implements BaseMchInterface, BaseUserInterface {
public class HardSpuRepertoryVo extends HardSpuRepertoryEntity implements BaseMchInterface, BaseUserInterface, BaseHardInterface {
/**
* 商品相关
@@ -42,5 +43,15 @@ public class HardSpuRepertoryVo extends HardSpuRepertoryEntity implements BaseMc
private String userAvatar;
/**
* 设备相关
*/
private Long hardId;
private String hardName;
private String hardType;
private String deviceCode;
}
@@ -0,0 +1,101 @@
package com.bsd.pjcloud.hard.controller;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.hard.api.entity.HardApptEntity;
import com.bsd.pjcloud.hard.service.HardApptService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Objects;
/**
* 设备预约管理
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/hard-appt")
@Tag(description = "hard-appt", name = "设备预约管理管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class HardApptController {
private final HardApptService hardApptService;
/* ************************************* start app start ************************************* */
@Operation(summary = "app预约时间列表", description = "app预约时间列表")
@GetMapping("/app/list")
public R<List<HardApptEntity>> appList() {
List<HardApptEntity> list = hardApptService.list(new LambdaQueryWrapper<HardApptEntity>()
.eq(HardApptEntity::getStatus, YesNoEnum.YES.getCode())
.orderByDesc(HardApptEntity::getSort)
);
return R.ok(list);
}
/* ************************************* end app end ************************************* */
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('hard_hardAppt_view')")
public R getHardApptPage(@ParameterObject Page page, @ParameterObject HardApptEntity dto) {
LambdaQueryWrapper<HardApptEntity> wrapper = new LambdaQueryWrapper<HardApptEntity>()
.like(ObjectUtil.isNotEmpty(dto.getTitle()), HardApptEntity::getTitle, dto.getTitle());
return R.ok(hardApptService.page(page, wrapper));
}
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('hard_hardAppt_view')")
public R getById(@PathVariable("id") Long id) {
return R.ok(hardApptService.getById(id));
}
@Operation(summary = "新增设备预约管理", description = "新增设备预约管理")
@SysLog("新增设备预约管理")
@PostMapping
@PreAuthorize("@pms.hasPermission('hard_hardAppt_add')")
public R save(@RequestBody HardApptEntity hardAppt) {
return R.ok(hardApptService.create(hardAppt));
}
@Operation(summary = "修改设备预约管理", description = "修改设备预约管理")
@SysLog("修改设备预约管理")
@PutMapping
@PreAuthorize("@pms.hasPermission('hard_hardAppt_edit')")
public R updateById(@RequestBody HardApptEntity hardAppt) {
return R.ok(hardApptService.edit(hardAppt));
}
@Operation(summary = "通过id删除设备预约管理", description = "通过id删除设备预约管理")
@SysLog("通过id删除设备预约管理")
@DeleteMapping
@PreAuthorize("@pms.hasPermission('hard_hardAppt_del')")
public R removeById(@RequestBody Long[] ids) {
hardApptService.delByIds(CollUtil.toList(ids));
return R.ok();
}
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('hard_hardAppt_export')")
public List<HardApptEntity> export(HardApptEntity hardAppt, Long[] ids) {
return hardApptService.list(Wrappers.lambdaQuery(hardAppt).in(ArrayUtil.isNotEmpty(ids), HardApptEntity::getId, ids));
}
}
@@ -6,12 +6,11 @@ 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.data.datascope.DataScope;
import com.bsd.pjcloud.common.idempotent.annotation.Idempotent;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
import com.bsd.pjcloud.common.security.util.SecurityUtils;
import com.bsd.pjcloud.hard.api.dto.HardAuthAppDto;
import com.bsd.pjcloud.hard.api.dto.HardAuthDto;
import com.bsd.pjcloud.hard.api.dto.HardGetAuthAppDto;
import com.bsd.pjcloud.hard.api.dto.*;
import com.bsd.pjcloud.hard.api.entity.HardAuthEntity;
import com.bsd.pjcloud.hard.api.vo.HardAuthVo;
import com.bsd.pjcloud.hard.api.vo.HardGetAuthAppVo;
@@ -25,6 +24,7 @@ import org.springframework.http.HttpHeaders;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@@ -61,6 +61,15 @@ public class HardAuthController {
/* ************************************* end app end ************************************* */
@Operation(summary = "流程错误手动处理", description = "流程错误手动处理")
@PostMapping("/error-change")
@Idempotent(expireTime = 5, info = "正在开门中,请勿重复操作")
public R errorChange(@Validated @RequestBody HardAuthErrorChangeDto dto) {
PjcloudUser user = SecurityUtils.getUser();
hardAuthService.errorChange(dto, user.getId());
return R.ok();
}
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page-join")
@PreAuthorize("@pms.hasPermission('hard_hardAuth_view')")
@@ -6,6 +6,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.data.datascope.DataScope;
import com.bsd.pjcloud.common.idempotent.annotation.Idempotent;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.common.security.annotation.Inner;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
@@ -90,6 +91,7 @@ public class HardDoorFlowController {
@Operation(summary = "上架开门", description = "上架开门")
@PostMapping("/app/open-repertory")
@Idempotent(expireTime = 5, info = "正在开门中,请勿重复操作")
public R<Long> openRepertory(@Validated @RequestBody HardDoorFlowOpenDto dto) {
PjcloudUser user = SecurityUtils.getUser();
dto.setFlowType(HardDoorFlowBizEnum.REPERTORY_OPEN);
@@ -98,10 +100,35 @@ public class HardDoorFlowController {
return R.ok(hardDoorFlowService.openDoorRepertory(dto));
}
@Operation(summary = "app检修开门", description = "app检修开门")
@PostMapping("/app/open-access")
@Idempotent(expireTime = 5, info = "正在开门中,请勿重复操作")
public R appOpenAccess(@Validated @RequestBody HardDoorFlowOpenDto dto) {
PjcloudUser user = SecurityUtils.getUser();
dto.setFlowType(HardDoorFlowBizEnum.ACCESS_OPEN);
dto.setOpenType(HardDoorOpenTypeEnum.MAINTENANCE_UNLOCK);
dto.setUserId(user.getId());
hardDoorFlowService.openDoorAccess(dto);
return R.ok();
}
@Operation(summary = "app检修开门", description = "app检修开门")
@PostMapping("/app/close-access")
@Idempotent(expireTime = 5, info = "正在关门中,请勿重复操作")
public R appCloseAccess(@Validated @RequestBody HardDoorFlowOpenDto dto) {
PjcloudUser user = SecurityUtils.getUser();
dto.setFlowType(HardDoorFlowBizEnum.ACCESS_OPEN);
dto.setOpenType(HardDoorOpenTypeEnum.MAINTENANCE_LOCK);
dto.setUserId(user.getId());
hardDoorFlowService.closeAccess(dto);
return R.ok();
}
/* ************************************* end app end ************************************* */
@Operation(summary = "检修开门", description = "检修开门")
@PostMapping("/open-access")
@Idempotent(expireTime = 5, info = "正在开门中,请勿重复操作")
public R openAccess(@Validated @RequestBody HardDoorFlowOpenDto dto) {
PjcloudUser user = SecurityUtils.getUser();
dto.setFlowType(HardDoorFlowBizEnum.ACCESS_OPEN);
@@ -113,6 +140,7 @@ public class HardDoorFlowController {
@Operation(summary = "检修关门", description = "检修关门")
@PostMapping("/close-access")
@Idempotent(expireTime = 5, info = "正在关门中,请勿重复操作")
public R closeAccess(@Validated @RequestBody HardDoorFlowOpenDto dto) {
PjcloudUser user = SecurityUtils.getUser();
dto.setFlowType(HardDoorFlowBizEnum.ACCESS_OPEN);
@@ -9,9 +9,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.hard.api.dto.manager.HardDoorCabinetDto;
import com.bsd.pjcloud.hard.api.dto.manager.HardDoorManagerDto;
import com.bsd.pjcloud.hard.api.dto.spu.HardChangeVolume;
import com.bsd.pjcloud.hard.api.entity.manager.HardDoorCabinetEntity;
import com.bsd.pjcloud.hard.api.entity.manager.HardDoorManagerEntity;
import com.bsd.pjcloud.hard.api.vo.manager.HardDoorCabinetVo;
import com.bsd.pjcloud.hard.api.vo.manager.HardDoorManagerVo;
import com.bsd.pjcloud.hard.service.HardDoorCabinetService;
import com.bsd.pjcloud.hard.service.HardDoorManagerService;
@@ -79,6 +82,12 @@ public class HardDoorManagerController {
return R.ok();
}
@Operation(summary = "柜门下拉查询", description = "柜门下拉查询")
@GetMapping("/select-cabinet")
public R<Page<HardDoorCabinetVo>> selectCabinet(@ParameterObject Page page, @ParameterObject HardDoorCabinetDto dto) {
return R.ok(hardDoorManagerService.selectCabinet(page, dto));
}
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('hard_hardDoorManager_view')")
@@ -106,7 +115,7 @@ public class HardDoorManagerController {
@GetMapping("/get-by-hard-id")
@PreAuthorize("@pms.hasPermission('hard_hardDoorManager_view')")
public R<HardDoorManagerVo> getByHardId(@RequestParam Long hardId) {
return R.ok(hardDoorManagerService.getByHardDoorId(hardId));
return R.ok(hardDoorManagerService.getByHardId(hardId));
}
@Operation(summary = "通过id删除智能柜设置", description = "通过id删除智能柜设置")
@@ -66,7 +66,7 @@ public class HardOrderTotalController {
/* ************************************* start app start ************************************* */
@Operation(summary = "app查询商户每天流水记录", description = "app查询订单列表根据权限")
@GetMapping("/app/mch-water-day")
public R appMchTotal(@ParameterObject Page page, @ParameterObject HardOrderDto dto) {
public R appMchWaterDay(@ParameterObject Page page, @ParameterObject HardOrderDto dto) {
PjcloudUser user = SecurityUtils.getUser();
// 查询用户部门
UserInfo userInfo = userService.getByUserId(user.getId()).getData();
@@ -85,6 +85,30 @@ public class HardOrderTotalController {
dto.setMchIds(mchDtoIds);
return R.ok(hardOrderTotalService.listCsByDay(page, dto, user));
}
@Operation(summary = "app查询商户全部流水记录", description = "app查询商户全部流水记录")
@GetMapping("/app/mch-water-total")
public R appMchWaterTotal(@ParameterObject HardOrderDto dto) {
PjcloudUser user = SecurityUtils.getUser();
// 查询用户部门
UserInfo userInfo = userService.getByUserId(user.getId()).getData();
dto.setIsFindCarList(false);
// 判断是否为合作超市管理员工
if (!hardManagerService.isSuperMarketAdmin(user)) return R.ok(new Page());
// 查询用户属于的商户
MchManageVo mch = mchService.getFirstMchByDeptId(userInfo.getSysUser().getDeptId()).getData();
if (ObjectUtil.isEmpty(mch)) throw new RuntimeException("该用户下不存在商户");
List<Long> mchDtoIds = new ArrayList<>(List.of(mch.getId()));
// 查询商户和下面的子商户
List<MchManageVo> mchList = mchService.getByParentId(mch.getId()).getData();
// 查询子商户
List<Long> mchIds = mchList.stream().map(MchManageVo::getId).toList();
mchDtoIds.addAll(mchIds);
dto.setMchIds(mchDtoIds);
return R.ok(hardOrderTotalService.mchWaterTotal(dto, user));
}
/* ************************************* end app end ************************************* */
@PostMapping("/page-list-sb")
@@ -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.data.datascope.DataScope;
import com.bsd.pjcloud.common.idempotent.annotation.Idempotent;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.hard.api.dto.spu.HardPutawayDto;
import com.bsd.pjcloud.hard.api.dto.spu.HardSpuDto;
@@ -45,6 +46,7 @@ public class HardSpuController {
@Operation(summary = "app上架", description = "上架")
@PostMapping("/app/putaway")
@Idempotent(expireTime = 5, info = "正在上架中,请勿重复操作")
public R appPutaway(@Valid @RequestBody HardPutawayDto dto) {
hardSpuService.putaway(dto);
return R.ok();
@@ -52,6 +54,7 @@ public class HardSpuController {
@Operation(summary = "app下架", description = "下架")
@PostMapping("/app/un-putaway")
@Idempotent(expireTime = 5, info = "正在下架中,请勿重复操作")
public R appUnPutaway(@Valid @RequestBody HardPutawayDto dto) {
hardSpuService.unPutaway(dto);
return R.ok();
@@ -69,6 +72,13 @@ public class HardSpuController {
return R.ok(hardSpuService.getByCabinetNo(hardId, cabinetNo));
}
@Operation(summary = "app商品类表", description = "app商品类表")
@GetMapping("/app/page")
public R appPage(@ParameterObject Page page, @ParameterObject HardSpuDto dto) {
DataScope dataScope = null;
return R.ok(hardSpuService.scopPageJoin(page, dto, dataScope));
}
/* ************************************* end APP end ************************************* */
@Operation(summary = "拉取旷世商品", description = "拉取旷世商品")
@@ -2,11 +2,13 @@ package com.bsd.pjcloud.hard.controller.spu;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.data.datascope.DataScope;
import com.bsd.pjcloud.common.idempotent.annotation.Idempotent;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
import com.bsd.pjcloud.common.security.util.SecurityUtils;
@@ -44,6 +46,7 @@ public class HardSpuRepertoryController {
@Operation(summary = "app上架完成", description = "app上架完成")
@PostMapping("/app/repertory-done")
@Idempotent(expireTime = 5, info = "正在操作中,请勿重复操作")
public R<Boolean> appRepertoryDone(@Valid @RequestBody DeductionSpuRepertoryDto body) {
PjcloudUser user = SecurityUtils.getUser();
return R.ok(hardSpuRepertoryService.appRepertoryDone(body, user.getId()));
@@ -78,9 +81,13 @@ public class HardSpuRepertoryController {
@SysLog("新增硬件商品库存更新记录")
@PostMapping
@PreAuthorize("@pms.hasPermission('hard_hardSpuRepertory_add')")
public R save(@Validated @RequestBody HardSpuRepertoryEntity hardSpuRepertory) {
@Idempotent(expireTime = 5, info = "正在上架中,请勿重复操作")
public R save(@Validated @RequestBody HardSpuRepertoryDto dto) {
if (ObjectUtil.isEmpty(dto.getCabinetId())) {
return R.failed("请选择所属柜门");
}
PjcloudUser user = SecurityUtils.getUser();
return R.ok(hardSpuRepertoryService.create(hardSpuRepertory, user));
return R.ok(hardSpuRepertoryService.create(dto, user));
}
@Operation(summary = "修改硬件商品库存更新记录", description = "修改硬件商品库存更新记录")
@@ -0,0 +1,11 @@
package com.bsd.pjcloud.hard.mapper;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.hard.api.entity.HardApptEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface HardApptMapper extends PjcloudBaseMapper<HardApptEntity> {
}
@@ -1,11 +1,17 @@
package com.bsd.pjcloud.hard.mapper.manager;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import com.bsd.pjcloud.hard.api.dto.manager.HardDoorCabinetDto;
import com.bsd.pjcloud.hard.api.entity.manager.HardDoorCabinetEntity;
import com.bsd.pjcloud.hard.api.vo.manager.HardDoorCabinetVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface HardDoorCabinetMapper extends PjcloudBaseMapper<HardDoorCabinetEntity> {
Page<HardDoorCabinetVo> scopePageJoin(Page page, @Param("dto") HardDoorCabinetDto dto, DataScope dataScope);
}
@@ -14,5 +14,7 @@ public interface HardDoorManagerMapper extends PjcloudBaseMapper<HardDoorManager
Page<HardDoorManagerVo> scopePageJoin(Page page, @Param("dto") HardDoorManagerDto dto, DataScope dataScope);
HardDoorManagerVo pageJoin(@Param("hardId") Long hardId);
HardDoorManagerVo pageJoinByHardDoorId(@Param("hardDoorId") Long hardDoorId);
HardDoorManagerVo pageJoinByHardId(@Param("hardId") Long hardId);
}
@@ -101,6 +101,8 @@ public interface HardOrderMapper extends PjcloudBaseMapper<HardOrderEntity> {
List<HardOrderCsVo> listCsByDay(@Param("dto") HardOrderDto totalDto);
HardOrderCsVo listCsTotal(@Param("dto") HardOrderDto totalDto);
List<HardOrderPayTypeVo> listOrerPayType(@Param("dto") HardOrderDto dto);
List<HardOrderSumAndCountVo> sumAndCount(@Param("dto") HardOrderSumAndCountDto dto);
@@ -0,0 +1,24 @@
package com.bsd.pjcloud.hard.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.hard.api.entity.HardApptEntity;
import java.util.ArrayList;
public interface HardApptService extends IService<HardApptEntity> {
/**
* 新增
*/
Long create(HardApptEntity hardAppt);
/**
* 修改
*/
Long edit(HardApptEntity hardAppt);
/**
* 删除
*/
void delByIds(ArrayList<Long> list);
}
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.hard.api.dto.HardAuthAppDto;
import com.bsd.pjcloud.hard.api.dto.HardAuthDto;
import com.bsd.pjcloud.hard.api.dto.HardAuthErrorChangeDto;
import com.bsd.pjcloud.hard.api.dto.HardGetAuthAppDto;
import com.bsd.pjcloud.hard.api.entity.HardAuthEntity;
import com.bsd.pjcloud.hard.api.vo.HardAuthVo;
@@ -29,4 +30,9 @@ public interface HardAuthService extends IService<HardAuthEntity> {
* 判断当前用户信誉
*/
boolean judgeUserCredit(Long userId);
/**
* 流程错误手动处理
*/
void errorChange(HardAuthErrorChangeDto dto, Long userId);
}
@@ -2,6 +2,7 @@ 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.admin.api.dto.UserInfo;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.hard.api.dto.HardBroadcastDto;
import com.bsd.pjcloud.hard.api.entity.HardBroadcastEntity;
@@ -15,7 +16,7 @@ public interface HardBroadcastService extends IService<HardBroadcastEntity> {
/**
* 添加线下食堂预约订单广播
*/
void addReserveOrderTask(HardOrderEntity orderdetail);
void addReserveOrderTask(HardOrderEntity orderdetail, UserInfo userInfo);
/**
* 完成硬件广播
@@ -1,13 +1,19 @@
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.common.data.datascope.DataScope;
import com.bsd.pjcloud.hard.api.dto.manager.HardDoorCabinetDto;
import com.bsd.pjcloud.hard.api.entity.manager.HardDoorCabinetEntity;
import com.bsd.pjcloud.hard.api.vo.manager.HardDoorCabinetVo;
import com.bsd.pjcloud.thirdparty.vo.door.DoorStatusVo;
import java.util.List;
public interface HardDoorCabinetService extends IService<HardDoorCabinetEntity> {
Page<HardDoorCabinetVo> scopePageJoin(Page page, HardDoorCabinetDto dto, DataScope dataScope);
void saveOrUpdate(Long hardDoorId, List<DoorStatusVo.Cabinet> list);
List<HardDoorCabinetEntity> getListByHardDoorId(Long hardDoorId);
@@ -3,19 +3,31 @@ 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.common.data.datascope.DataScope;
import com.bsd.pjcloud.hard.api.dto.manager.HardDoorCabinetDto;
import com.bsd.pjcloud.hard.api.dto.manager.HardDoorManagerDto;
import com.bsd.pjcloud.hard.api.dto.spu.HardChangeVolume;
import com.bsd.pjcloud.hard.api.entity.manager.HardDoorManagerEntity;
import com.bsd.pjcloud.hard.api.vo.manager.HardDoorCabinetVo;
import com.bsd.pjcloud.hard.api.vo.manager.HardDoorManagerVo;
public interface HardDoorManagerService extends IService<HardDoorManagerEntity> {
Page<HardDoorManagerVo> scopePageJoin(Page page, HardDoorManagerDto dto, DataScope dataScope);
/**
* 柜门下拉查询
*/
Page<HardDoorCabinetVo> selectCabinet(Page page, HardDoorCabinetDto dto);
/**
* 根据智能硬件id查询详情
*/
HardDoorManagerVo getByHardDoorId(Long hardDoorId);
/**
* 根据硬件id查询详情
*/
HardDoorManagerVo getByHardDoorId(Long hardId);
HardDoorManagerVo getByHardId(Long hardId);
/**
* 根据硬件设备编号查询详情
@@ -2,6 +2,7 @@ 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.admin.api.dto.UserInfo;
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
@@ -92,5 +93,5 @@ public interface HardOrderService extends IService<HardOrderEntity> {
/**
* 创建订单后发送mq消息
*/
void createOrderAfterSendMqMsg(Long orderId);
void createOrderAfterSendMqMsg(Long orderId, UserInfo userInfo);
}
@@ -26,6 +26,11 @@ public interface HardOrderTotalService {
*/
List<HardOrderCsVo> listCsByDay(Page page, HardOrderDto dto, PjcloudUser user);
/**
* 查询商户总共流水记录
*/
HardOrderCsVo mchWaterTotal(HardOrderDto dto, PjcloudUser user);
/**
* 部门交易记录
*/
@@ -45,4 +50,5 @@ public interface HardOrderTotalService {
* 统计每天、每周、每月、每年的交易人数和次数
*/
HardChartLatitudeVo chartLatitude(Long merchantId);
}
@@ -19,7 +19,7 @@ public interface HardSpuRepertoryService extends IService<HardSpuRepertoryEntity
/**
* 新增
*/
Long create(HardSpuRepertoryEntity entity, PjcloudUser user);
Long create(HardSpuRepertoryDto dto, PjcloudUser user);
/**
* 修改
@@ -6,6 +6,7 @@ import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.hard.api.dto.spu.DeductionSpuStockDto;
import com.bsd.pjcloud.hard.api.dto.spu.HardPutawayDto;
import com.bsd.pjcloud.hard.api.dto.spu.HardSpuDto;
import com.bsd.pjcloud.hard.api.entity.HardDoorFlowEntity;
import com.bsd.pjcloud.hard.api.entity.spu.HardSpuEntity;
import com.bsd.pjcloud.hard.api.vo.spu.HardSpuJoinVo;
import com.bsd.pjcloud.hard.api.vo.spu.HardSpuVo;
@@ -43,7 +44,7 @@ public interface HardSpuService extends IService<HardSpuEntity> {
/**
* 根据 hardwareId 和 cabinetNo 查询商品
*/
List<Map<Integer, List<HardSpuJoinVo>>> getByCabinetNo(Long hardId, String cabinetNo);
List<Map<Integer, List<HardSpuJoinVo>>> getByCabinetNo(Long Long, String cabinetNo);
/**
* 查询货柜补货商品列表
@@ -73,5 +74,5 @@ public interface HardSpuService extends IService<HardSpuEntity> {
/**
* 扣减库存
*/
Boolean deductionSpuStock(List<DeductionSpuStockDto> list);
Boolean deductionSpuStock(HardDoorFlowEntity hardDoorFlow, List<DeductionSpuStockDto> list);
}
@@ -0,0 +1,71 @@
package com.bsd.pjcloud.hard.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.hard.api.entity.HardApptEntity;
import com.bsd.pjcloud.hard.mapper.HardApptMapper;
import com.bsd.pjcloud.hard.service.HardApptService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.util.ArrayList;
/**
* 设备预约管理
*/
@Validated
@Slf4j
@RequiredArgsConstructor
@Service
public class HardApptServiceImpl extends ServiceImpl<HardApptMapper, HardApptEntity> implements HardApptService {
/**
* 新增
*/
@Override
public Long create(HardApptEntity dto) {
// title不能重复
if (existTitle(dto.getTitle(), null)) {
throw new RuntimeException("标题不能重复");
}
baseMapper.insert(dto);
return 0L;
}
/**
* 修改
*/
@Override
public Long edit(HardApptEntity dto) {
// title不能重复
if (existTitle(dto.getTitle(), dto.getId())) {
throw new RuntimeException("标题不能重复");
}
baseMapper.updateById(dto);
return dto.getId();
}
/**
* 删除
*/
@Override
public void delByIds(ArrayList<Long> list) {
if (ObjectUtil.isEmpty(list)) return;
baseMapper.deleteBatchIds(list);
}
private boolean existTitle(String title, Long id) {
Long count = baseMapper.selectCount(new LambdaQueryWrapper<HardApptEntity>()
.eq(ObjectUtil.isNotEmpty(title), HardApptEntity::getTitle, title)
.ne(ObjectUtil.isNotEmpty(id), HardApptEntity::getId, id)
);
if (ObjectUtil.isNotEmpty(id)) {
return count >= 1;
}
return count > 0;
}
}
@@ -14,26 +14,25 @@ import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.hard.api.constant.HardAuthTypeEnum;
import com.bsd.pjcloud.hard.api.constant.flow.HardDoorFlowBizEnum;
import com.bsd.pjcloud.hard.api.constant.HardDoorOpenTypeEnum;
import com.bsd.pjcloud.hard.api.dto.HardAuthAppDto;
import com.bsd.pjcloud.hard.api.dto.HardAuthDto;
import com.bsd.pjcloud.hard.api.dto.HardDoorFlowOpenDto;
import com.bsd.pjcloud.hard.api.dto.HardGetAuthAppDto;
import com.bsd.pjcloud.hard.api.dto.*;
import com.bsd.pjcloud.hard.api.dto.manager.HardManagerDto;
import com.bsd.pjcloud.hard.api.entity.HardAuthEntity;
import com.bsd.pjcloud.hard.api.entity.HardDoorFlowEntity;
import com.bsd.pjcloud.hard.api.entity.manager.HardManagerEntity;
import com.bsd.pjcloud.hard.api.utils.HardUtil;
import com.bsd.pjcloud.hard.api.vo.HardAuthVo;
import com.bsd.pjcloud.hard.api.vo.HardGetAuthAppVo;
import com.bsd.pjcloud.hard.api.vo.manager.HardDoorManagerVo;
import com.bsd.pjcloud.hard.mapper.HardAuthMapper;
import com.bsd.pjcloud.hard.mapper.manager.HardDoorManagerMapper;
import com.bsd.pjcloud.hard.mapper.manager.HardManagerMapper;
import com.bsd.pjcloud.hard.service.HardAuthService;
import com.bsd.pjcloud.hard.service.HardDoorFlowService;
import com.bsd.pjcloud.hard.service.HardDoorManagerService;
import com.bsd.pjcloud.hard.service.HardOrderService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import java.time.LocalDateTime;
@@ -51,9 +50,9 @@ public class HardAuthServiceImpl extends ServiceImpl<HardAuthMapper, HardAuthEnt
private final HardDoorManagerService hardDoorManagerService;
private final HardDoorFlowService hardDoorFlowService;
private final HardOrderService hardOrderService;
private final HardManagerMapper hardManagerMapper;
private final HardDoorManagerMapper hardDoorManagerMapper;
private final RemoteUserService remoteUserService;
@@ -93,12 +92,13 @@ public class HardAuthServiceImpl extends ServiceImpl<HardAuthMapper, HardAuthEnt
* app智能柜授权
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Long appAuthHardDoor(HardAuthAppDto dto) {
// 查询授权信息
HardAuthEntity authEntity = baseMapper.selectById(dto.getAuthId());
if (ObjectUtil.isEmpty(authEntity)) throw new RuntimeException("授权信息不存在");
// 查询设备信息
HardDoorManagerVo hardDoorDetail = hardDoorManagerService.getByHardDoorId(authEntity.getHardId());
HardDoorManagerVo hardDoorDetail = hardDoorManagerService.getByHardId(authEntity.getHardId());
if (ObjectUtil.isEmpty(hardDoorDetail)) throw new RuntimeException("授权信息不存在");
HardAuthEntity updateObj = HardAuthEntity.builder().id(dto.getAuthId()).authStatus(dto.getAuthStatus()).authTime(LocalDateTime.now()).build();
baseMapper.updateById(updateObj);
@@ -130,6 +130,29 @@ public class HardAuthServiceImpl extends ServiceImpl<HardAuthMapper, HardAuthEnt
return count <= 5;
}
/**
* 流程错误手动处理
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void errorChange(HardAuthErrorChangeDto dto, Long userId) {
HardDoorFlowEntity hardDoorFlow = hardDoorFlowService.getById(dto.getFlowId());
if (ObjectUtil.isEmpty(hardDoorFlow)) {
throw new RuntimeException("智能柜子购买流程不存在");
}
HardAuthEntity hardAuth = baseMapper.selectById(hardDoorFlow.getAuthId());
HardAuthEntity updateObj = new HardAuthEntity();
updateObj.setId(hardAuth.getId());
updateObj.setManualChangeUserId(userId);
updateObj.setIsManualChange(YesNoEnum.YES.getCode());
updateObj.setManualChangeTime(LocalDateTime.now());
updateObj.setManualChangeRemark(dto.getRemark());
updateObj.setManualChangePic(dto.getImage());
baseMapper.updateById(updateObj);
// 更新订单状态
hardOrderService.cancelHardDoorOrder(hardDoorFlow.getOrderId());
}
private void disposeList(List<HardAuthVo> list, HardAuthDto dto) {
if (ObjectUtil.isEmpty(list)) return;
// 设备
@@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.admin.api.dto.UserInfo;
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
import com.bsd.pjcloud.admin.api.utils.DataUtil;
import com.bsd.pjcloud.admin.api.vo.UserVO;
@@ -24,6 +25,9 @@ import com.bsd.pjcloud.hard.api.vo.HardBroadcastVo;
import com.bsd.pjcloud.hard.mapper.HardBroadcastMapper;
import com.bsd.pjcloud.hard.mapper.manager.HardManagerMapper;
import com.bsd.pjcloud.hard.service.HardBroadcastService;
import com.bsd.pjcloud.mqtt.api.feign.RemoteMqttEventService;
import com.bsd.pjcloud.mqtt.constant.MqttActionEnum;
import com.bsd.pjcloud.mqtt.dto.hard.HardTakeFoodBroadcastMsg;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -47,6 +51,8 @@ public class HardBroadcastServiceImpl extends ServiceImpl<HardBroadcastMapper, H
private final RemoteUserService remoteUserService;
private final RemoteMqttEventService remoteMqttEventService;
@Override
public Page<HardBroadcastVo> scopePageJoin(Page page, HardBroadcastDto dto, DataScope dataScope) {
Page<HardBroadcastVo> pageList = baseMapper.scopePageJoin(page, dto, dataScope);
@@ -58,17 +64,17 @@ public class HardBroadcastServiceImpl extends ServiceImpl<HardBroadcastMapper, H
* 添加线下食堂预约订单广播
*/
@Override
public void addReserveOrderTask(HardOrderEntity orderdetail) {
public void addReserveOrderTask(HardOrderEntity orderdetail, UserInfo userInfo) {
if (ObjectUtil.isEmpty(orderdetail)) return;
HardTypeEnum hardTypeEnum = HardTypeEnum.valueOfByType(orderdetail.getSysType());
if (ObjectUtil.isEmpty(orderdetail)) {
log.error("|{}|addReserveOrderTask发送mq消息失败,设备类型错误hardType不存在hardType|{}|", TAG, orderdetail.getSysType());
log.error("|{}|发送线下订餐mq消息失败,设备类型错误hardType不存在hardType|{}|", TAG, orderdetail.getSysType());
return;
}
if (ObjectUtil.notEqual(hardTypeEnum, HardTypeEnum.CANTEEN)) return;
HardOrderTypeEnum hardOrderType = HardOrderTypeEnum.valueOfByType(orderdetail.getOrderType());
if (ObjectUtil.isEmpty(hardOrderType)) {
log.error("|{}|addReserveOrderTask发送mq消息失败,订餐类型错误hardType不存在hardType|{}|", TAG, orderdetail.getOrderType());
log.error("|{}|发送线下订餐mq消息失败,订餐类型错误hardType不存在hardType|{}|", TAG, orderdetail.getOrderType());
return;
}
if (ObjectUtil.notEqual(hardOrderType, HardOrderTypeEnum.RESERVE)) return;
@@ -77,25 +83,55 @@ public class HardBroadcastServiceImpl extends ServiceImpl<HardBroadcastMapper, H
.eq(HardBroadcastEntity::getBizId, orderdetail.getId())
);
if (ObjectUtil.isNotEmpty(broadcastDetail)) {
log.error("|{}|addReserveOrderTask发送mq消息失败,广播已存在|{}|", TAG, orderdetail.getId());
log.error("|{}|发送线下订餐mq消息失败,广播已存在|{}|", TAG, orderdetail.getId());
return;
}
// 查询设备
HardManagerEntity hardDetail = hardManagerMapper.selectOne(new LambdaQueryWrapper<HardManagerEntity>()
.eq(HardManagerEntity::getMerchantId, orderdetail.getMerchantId())
.eq(HardManagerEntity::getIsTakeFood, YesNoEnum.YES.getCode())
);
if (ObjectUtil.isEmpty(hardDetail)) {
log.error("|{}|发送线下订餐mq消息失败,默认订餐设备不存在|{}|", TAG, orderdetail.getId());
return;
}
String content = "";
String phone = userInfo.getSysUser().getPhone();
if (ObjectUtil.isNotEmpty(phone) && phone.length() >= 4) {
content = phone.substring(phone.length() - 4);
}
if (ObjectUtil.isEmpty(content)) {
log.error("|{}|发送线下订餐mq消息失败,生成发送消息错误|{}|", TAG, orderdetail.getId());
return;
}
HardBroadcastEntity saveObj = HardBroadcastEntity.builder()
.userId(orderdetail.getUserId())
.hardId(orderdetail.getHardId())
.topic("")
.topic(hardDetail.getMainTopic())
.bizType(HardBroadcastEnum.OFFLINE_CANTEEN_RESERVE.getType())
.bizId(String.valueOf(orderdetail.getId()))
.title(HardBroadcastEnum.OFFLINE_CANTEEN_RESERVE.getDescription())
.content("")
.content(content)
.broadcastCount(0)
.broadcastMaxCount(20)
.isBroadcast(YesNoEnum.YES.getCode())
.isDone(YesNoEnum.NO.getCode())
.build();
baseMapper.insert(saveObj);
// 发送mq
HardTakeFoodBroadcastMsg msg = new HardTakeFoodBroadcastMsg();
msg.setTopic(saveObj.getTopic());
msg.setAction(MqttActionEnum.TAKE_FOOD_BROADCAST);
msg.setUserId(String.valueOf(userInfo.getSysUser().getUserId()));
msg.setUserName(userInfo.getSysUser().getName());
msg.setUserMobile(userInfo.getSysUser().getPhone());
msg.setId(String.valueOf(saveObj.getId()));
msg.setTitle(saveObj.getTitle());
msg.setContent(saveObj.getContent());
msg.setBroadcastMaxCount(saveObj.getBroadcastMaxCount());
msg.setProductDesc(orderdetail.getProductDesc());
msg.setPayPrice(orderdetail.getPayPrice());
remoteMqttEventService.sendTakeFoodBroadcast(msg);
}
/**
@@ -185,6 +185,7 @@ public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, Har
* 购买开门
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void openDoorPay(HardDoorFlowOpenDto dto, HardDoorManagerVo hardDoorDetail) {
if (ObjectUtil.isNotEmpty(dto.getHardDoorFlowId()) || ObjectUtil.isEmpty(hardDoorDetail)) {
return;
@@ -340,7 +341,7 @@ public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, Har
String ksFlowCode = dto.getState().getCode();
String ksRecognitionCode = dto.getResult().getStatus().getCode();
if (ObjectUtil.notEqual(ksFlowCode, "2") || ObjectUtil.notEqual(ksRecognitionCode, "2")) {
if (ObjectUtil.equals(ksFlowCode, "2") && ObjectUtil.notEqual(ksRecognitionCode, "3")) {
if (ObjectUtil.equals(ksFlowCode, "2") && ObjectUtil.equals(ksRecognitionCode, "3")) {
// 未拿商品取消订单
hardOrderService.cancelHardDoorOrder(flowDetail.getOrderId());
getSelf().flowStatusControl(flowDetail, null, dto, "");
@@ -518,6 +519,11 @@ public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, Har
if (ObjectUtil.isNotEmpty(hardManager)) {
HardUtil.convertHard(detail, hardManager);
}
// 设备id
HardAuthEntity hardAuth = hardAuthService.getById(detail.getAuthId());
if (ObjectUtil.isNotEmpty(hardAuth)) {
detail.setHardAuth(hardAuth);
}
}
private HardDoorFlowServiceImpl getSelf() {
@@ -4,12 +4,16 @@ import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.admin.api.feign.RemoteFileService;
import com.bsd.pjcloud.common.core.util.QRCodeImageGenerator;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.hard.api.dto.manager.HardDoorCabinetDto;
import com.bsd.pjcloud.hard.api.entity.manager.HardDoorCabinetEntity;
import com.bsd.pjcloud.hard.api.vo.manager.HardDoorCabinetCodeVo;
import com.bsd.pjcloud.hard.api.vo.manager.HardDoorCabinetVo;
import com.bsd.pjcloud.hard.mapper.manager.HardDoorCabinetMapper;
import com.bsd.pjcloud.hard.service.HardDoorCabinetService;
import com.bsd.pjcloud.thirdparty.vo.door.DoorStatusVo;
@@ -36,6 +40,11 @@ public class HardDoorCabinetServiceImpl extends ServiceImpl<HardDoorCabinetMappe
private final RemoteFileService remoteFileService;
@Override
public Page<HardDoorCabinetVo> scopePageJoin(Page page, HardDoorCabinetDto dto, DataScope dataScope) {
return baseMapper.scopePageJoin(page, dto, dataScope);
}
@Override
public void saveOrUpdate(Long hardDoorId, List<DoorStatusVo.Cabinet> list) {
List<HardDoorCabinetEntity> cabinetList = baseMapper.selectList(new LambdaQueryWrapper<HardDoorCabinetEntity>()
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.common.core.util.CollectionUtils;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.hard.api.dto.manager.HardDoorCabinetDto;
import com.bsd.pjcloud.hard.api.dto.manager.HardDoorManagerDto;
import com.bsd.pjcloud.hard.api.dto.manager.HardManagerDto;
import com.bsd.pjcloud.hard.api.dto.spu.HardChangeVolume;
@@ -14,6 +15,7 @@ import com.bsd.pjcloud.hard.api.entity.manager.HardDoorCabinetEntity;
import com.bsd.pjcloud.hard.api.entity.manager.HardDoorManagerEntity;
import com.bsd.pjcloud.hard.api.entity.manager.HardManagerEntity;
import com.bsd.pjcloud.hard.api.utils.HardUtil;
import com.bsd.pjcloud.hard.api.vo.manager.HardDoorCabinetVo;
import com.bsd.pjcloud.hard.api.vo.manager.HardDoorManagerVo;
import com.bsd.pjcloud.hard.mapper.manager.HardDoorManagerMapper;
import com.bsd.pjcloud.hard.mapper.manager.HardManagerMapper;
@@ -55,12 +57,36 @@ public class HardDoorManagerServiceImpl extends ServiceImpl<HardDoorManagerMappe
return pageList;
}
/**
* 柜门下拉查询
*/
@Override
public Page<HardDoorCabinetVo> selectCabinet(Page page, HardDoorCabinetDto dto) {
DataScope dataScope = new DataScope();
return hardDoorCabinetService.scopePageJoin(page, dto, dataScope);
}
/**
* 根据硬件id查询详情
*/
@Override
public HardDoorManagerVo getByHardDoorId(Long hardId) {
HardDoorManagerVo hardDoor = baseMapper.pageJoin(hardId);
public HardDoorManagerVo getByHardDoorId(Long hardDoorId) {
HardDoorManagerVo hardDoor = baseMapper.pageJoinByHardDoorId(hardDoorId);
if (ObjectUtil.isNotEmpty(hardDoor)) {
List<HardDoorCabinetEntity> cabinetList = hardDoorCabinetService.getListByHardDoorId(hardDoor.getId());
if (ObjectUtil.isNotEmpty(cabinetList)) {
hardDoor.setCabinetList(cabinetList);
}
}
return hardDoor;
}
/**
* 根据硬件id查询详情
*/
@Override
public HardDoorManagerVo getByHardId(Long hardId) {
HardDoorManagerVo hardDoor = baseMapper.pageJoinByHardId(hardId);
if (ObjectUtil.isNotEmpty(hardDoor)) {
List<HardDoorCabinetEntity> cabinetList = hardDoorCabinetService.getListByHardDoorId(hardDoor.getId());
if (ObjectUtil.isNotEmpty(cabinetList)) {
@@ -119,6 +145,9 @@ public class HardDoorManagerServiceImpl extends ServiceImpl<HardDoorManagerMappe
if (!registerVo.isSuccess()) {
throw new RuntimeException(registerVo.getMessage());
}
if (ObjectUtil.isEmpty(registerVo.getDeviceCode())) {
throw new RuntimeException("设备注册失败");
}
// 设备绑定
DoorBindDto bindDto = new DoorBindDto();
bindDto.setImei(dto.getImei());
@@ -38,6 +38,7 @@ import com.bsd.pjcloud.hard.api.entity.order.HardOrderEntity;
import com.bsd.pjcloud.hard.api.entity.order.HardParentCarEntity;
import com.bsd.pjcloud.hard.api.entity.spu.HardSpuEntity;
import com.bsd.pjcloud.hard.api.utils.HardUtil;
import com.bsd.pjcloud.hard.api.vo.HardDoorFlowVo;
import com.bsd.pjcloud.hard.api.vo.manager.HardManagerVo;
import com.bsd.pjcloud.hard.api.vo.order.HardCarVo;
import com.bsd.pjcloud.hard.api.vo.order.HardOrderVo;
@@ -93,6 +94,8 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
private final HardParentCarServiceImpl hardParentCarServiceImpl;
@Lazy
private final HardInvoiceService hardInvoiceService;
@Lazy
private final HardDoorFlowService hardDoorFlowService;
private final HardBroadcastService hardBroadcastService;
private final HardSpuService hardSpuService;
@@ -284,7 +287,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
// 钱包扣款
if (isPay) getSelf().fastReduceBalance(orderObj);
// 发送mq消息
getSelf().createOrderAfterSendMqMsg(orderObj.getId());
getSelf().createOrderAfterSendMqMsg(orderObj.getId(), userDetail);
return orderObj.getId();
}
@@ -351,7 +354,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
// 是否需要创建二维码
getSelf().generateCode(orderObj);
// 发送mq消息
getSelf().createOrderAfterSendMqMsg(orderObj.getId());
getSelf().createOrderAfterSendMqMsg(orderObj.getId(), userDetail);
// 扣减库存
getSelf().fastenerInventory(orderObj, YesNoEnum.YES);
return orderObj.getId();
@@ -698,7 +701,13 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
entity.setIncrCount(v.getProductCount());
return entity;
}).toList();
Boolean isDeduction = hardSpuService.deductionSpuStock(list);
// 查询订单流程
HardDoorFlowVo doorFlow = hardDoorFlowService.getByOrderId(order.getId());
if (ObjectUtil.isEmpty(doorFlow)) {
log.info("|{}|{},失败,order不存在:|{}|,isReduce:|{}|,params:|{}|", TAG, CarErrorMsg, JSON.toJSON(order), isReduce, JSON.toJSON(list));
return;
}
Boolean isDeduction = hardSpuService.deductionSpuStock(doorFlow, list);
if (!isDeduction) {
log.info("|{}|{},失败,order:|{}|,isReduce:|{}|,params:|{}|", TAG, CarErrorMsg, JSON.toJSON(order), isReduce, JSON.toJSON(list));
throw new RuntimeException("扣减智能柜库存" + CarErrorMsg + "错误");
@@ -710,7 +719,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
// 发送mq消息
@Override
public void createOrderAfterSendMqMsg(Long orderId) {
public void createOrderAfterSendMqMsg(Long orderId, UserInfo userInfo) {
try {
HardOrderEntity orderdetail = baseMapper.selectById(orderId);
if (ObjectUtil.isEmpty(orderdetail)) {
@@ -738,7 +747,7 @@ public class HardOrderServiceImpl extends ServiceImpl<HardOrderMapper, HardOrder
}
// 发送订餐mq
if (ObjectUtil.equals(hardOrderType, HardOrderTypeEnum.RESERVE)) {
hardBroadcastService.addReserveOrderTask(orderdetail);
hardBroadcastService.addReserveOrderTask(orderdetail, userInfo);
}
}
}
@@ -87,7 +87,7 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
DataScope refundDataScope = DataScope.of().func(DataScopeFuncEnum.ALL);
refundDataScope.setScopeDeptName("merchant_dept_id");
List<HardOrderSbVo> refundList = hardOrderMapper.listSb(refundDto, refundDataScope);
// 盈利
// 消费净次数
HardOrderDto profitDto = BeanUtil.toBean(dto, HardOrderDto.class);
profitDto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes());
DataScope profitDataScope = DataScope.of().func(DataScopeFuncEnum.ALL);
@@ -102,7 +102,7 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
v.setTotalRefundCount(i.getTotalPayCount());
});
}
// 盈利
// 消费净次数
if (ObjectUtil.isNotEmpty(profitList)) {
profitList.stream().filter(i -> ObjectUtil.equals(i.getHardId(), v.getHardId())).findFirst().ifPresent(i -> {
v.setTotalProfitPrice(i.getTotalPayPrice());
@@ -153,7 +153,7 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
DataScope refundDataScope = DataScope.of();
refundDataScope.setScopeDeptName("merchant_dept_id");
List<HardOrderCsVo> refundList = hardOrderMapper.listCs(refundDto, refundDataScope);
// 盈利
// 消费净次数
HardOrderDto profitDto = BeanUtil.toBean(dto, HardOrderDto.class);
profitDto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes());
DataScope profitDataScope = DataScope.of();
@@ -167,7 +167,7 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
v.setTotalRefundCount(i.getTotalPayCount());
});
}
// 盈利
// 消费净次数
if (ObjectUtil.isNotEmpty(profitList)) {
profitList.stream().filter(i -> ObjectUtil.equals(i.getMerchantId(), v.getMerchantId())).findFirst().ifPresent(i -> {
v.setTotalProfitPrice(i.getTotalPayPrice());
@@ -203,7 +203,7 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
refundDto.setOrderStatusCodes(HardOrderStatusEnum.getPayErrorCodes());
return hardOrderMapper.listCsByDay(refundDto);
});
// 盈利
// 消费净次数
CompletableFuture<List<HardOrderCsVo>> profitListFuture = CompletableFuture.supplyAsync(() -> {
HardOrderDto profitDto = BeanUtil.toBean(dto, HardOrderDto.class);
profitDto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes());
@@ -222,7 +222,7 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
v.setTotalRefundCount(i.getTotalPayCount());
});
}
// 盈利
// 消费净次数
if (ObjectUtil.isNotEmpty(profitList)) {
profitList.stream().filter(i -> ObjectUtil.equals(i.getDay(), v.getDay()) && ObjectUtil.equals(i.getMerchantId(), v.getMerchantId())).findFirst().ifPresent(i -> {
v.setTotalProfitPrice(i.getTotalPayPrice());
@@ -244,6 +244,61 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
return totalList;
}
/**
* 查询商户总共流水记录
*/
@Override
public HardOrderCsVo mchWaterTotal(HardOrderDto dto, PjcloudUser user) {
HardOrderCsVo result = new HardOrderCsVo();
// 查询总流水
CompletableFuture<HardOrderCsVo> totalFuture = CompletableFuture.supplyAsync(() -> {
HardOrderDto totalDto = BeanUtil.toBean(dto, HardOrderDto.class);
totalDto.setOrderStatusCodes(HardOrderStatusEnum.getPayPrice());
return hardOrderMapper.listCsTotal(totalDto);
});
// 扣款总流水
CompletableFuture<HardOrderCsVo> refundFuture = CompletableFuture.supplyAsync(() -> {
HardOrderDto refundDto = BeanUtil.toBean(dto, HardOrderDto.class);
refundDto.setOrderStatusCodes(HardOrderStatusEnum.getPayErrorCodes());
return hardOrderMapper.listCsTotal(refundDto);
});
// 消费净次数
CompletableFuture<HardOrderCsVo> profitFuture = CompletableFuture.supplyAsync(() -> {
HardOrderDto profitDto = BeanUtil.toBean(dto, HardOrderDto.class);
profitDto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes());
return hardOrderMapper.listCsTotal(profitDto);
});
CompletableFuture<Void> allFutures = CompletableFuture.allOf(totalFuture, refundFuture, profitFuture);
allFutures.join();
HardOrderCsVo totalList = totalFuture.join();
HardOrderCsVo refundList = refundFuture.join();
HardOrderCsVo profitList = profitFuture.join();
// 聚合一下数据
if (ObjectUtil.isEmpty(totalList)) return result;
if (ObjectUtil.isNotEmpty(refundList)) {
if (ObjectUtil.isNotEmpty(refundList.getTotalPayPrice())) {
totalList.setTotalRefundPrice(refundList.getTotalPayPrice());
}
if (ObjectUtil.isNotEmpty(refundList.getTotalPayCount())) {
totalList.setTotalRefundCount(refundList.getTotalPayCount());
}
}
if (ObjectUtil.isNotEmpty(profitList)) {
if (ObjectUtil.isNotEmpty(profitList.getTotalPayPrice())) {
totalList.setTotalProfitPrice(profitList.getTotalPayPrice());
}
if (ObjectUtil.isNotEmpty(profitList.getTotalPayCount())) {
totalList.setTotalProfitCount(profitList.getTotalPayCount());
}
}
// 商户
MchManageVo mchDetail = remoteMchService.getById(totalList.getMerchantId()).getData();
if (ObjectUtil.isNotEmpty(mchDetail)) {
WalletDataUtil.convertMch(result, mchDetail);
}
return result;
}
/**
* 部门交易记录
*/
@@ -353,7 +408,7 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
}
return hardOrderMapper.sumAndCount(refundDto);
});
// 查看盈利流水
// 消费净次数
CompletableFuture<List<HardOrderSumAndCountVo>> profitFuture = CompletableFuture.supplyAsync(() -> {
HardOrderSumAndCountDto refundDto = new HardOrderSumAndCountDto();
refundDto.setUserDeptIds(deptIds);
@@ -385,7 +440,8 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
}
if (ObjectUtil.isNotEmpty(walletReduceList)) {
walletReduceList.stream().filter(i -> ObjectUtil.equals(i.getDeptId(), v.getDeptId())).findFirst().ifPresent(i -> {
v.setWalletReducePrice(i.getSum());
// v.setWalletReducePrice(i.getSum());
v.setWalletReducePrice(Math.abs(i.getSum()));
v.setWalletReduceCount(i.getCount());
});
}
@@ -397,7 +453,8 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
}
if (ObjectUtil.isNotEmpty(walletOnceReduceList)) {
walletOnceReduceList.stream().filter(i -> ObjectUtil.equals(i.getDeptId(), v.getDeptId())).findFirst().ifPresent(i -> {
v.setWalletOnceReducePrice(i.getSum());
// v.setWalletOnceReducePrice(i.getSum());
v.setWalletOnceReducePrice(Math.abs(i.getSum()));
v.setWalletOnceReduceCount(i.getCount());
});
}
@@ -15,14 +15,14 @@ import com.bsd.pjcloud.hard.api.constant.spu.HardSpuRepertoryTypeEnum;
import com.bsd.pjcloud.hard.api.dto.spu.DeductionSpuRepertoryDto;
import com.bsd.pjcloud.hard.api.dto.spu.HardSpuRepertoryDto;
import com.bsd.pjcloud.hard.api.entity.HardDoorFlowEntity;
import com.bsd.pjcloud.hard.api.entity.manager.HardDoorCabinetEntity;
import com.bsd.pjcloud.hard.api.entity.spu.HardSpuEntity;
import com.bsd.pjcloud.hard.api.entity.spu.HardSpuJoinEntity;
import com.bsd.pjcloud.hard.api.entity.spu.HardSpuRepertoryEntity;
import com.bsd.pjcloud.hard.api.vo.spu.HardSpuRepertoryVo;
import com.bsd.pjcloud.hard.mapper.manager.HardManagerMapper;
import com.bsd.pjcloud.hard.mapper.spu.HardSpuRepertoryMapper;
import com.bsd.pjcloud.hard.service.HardDoorFlowService;
import com.bsd.pjcloud.hard.service.HardSpuRepertoryService;
import com.bsd.pjcloud.hard.service.HardSpuService;
import com.bsd.pjcloud.hard.service.*;
import com.bsd.pjcloud.wallet.api.feign.RemoteMchService;
import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
@@ -46,6 +46,8 @@ public class HardSpuRepertoryServiceImpl extends ServiceImpl<HardSpuRepertoryMap
private final HardSpuService hardSpuService;
private final HardDoorFlowService hardDoorFlowService;
private final HardDoorCabinetService hardDoorCabinetService;
private final HardSpuJoinService hardSpuJoinService;
private final RemoteMchService remoteMchService;
private final RemoteUserService remoteUserService;
@@ -62,9 +64,9 @@ public class HardSpuRepertoryServiceImpl extends ServiceImpl<HardSpuRepertoryMap
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Long create(HardSpuRepertoryEntity entity, PjcloudUser user) {
public Long create(HardSpuRepertoryDto dto, PjcloudUser user) {
// 查询商品
HardSpuEntity spuDetail = hardSpuService.getById(entity.getSpuId());
HardSpuEntity spuDetail = hardSpuService.getById(dto.getSpuId());
if (ObjectUtil.isEmpty(spuDetail)) {
throw new RuntimeException("商品不存在");
}
@@ -74,20 +76,42 @@ public class HardSpuRepertoryServiceImpl extends ServiceImpl<HardSpuRepertoryMap
if (ObjectUtil.equals(spuDetail.getPrice(), 0)) {
throw new RuntimeException("商品价格不能为0");
}
// 查询货柜
HardDoorCabinetEntity doorCabinet = hardDoorCabinetService.getById(dto.getCabinetId());
if (ObjectUtil.isEmpty(doorCabinet)) {
throw new RuntimeException("货柜不存在");
}
dto.setHardDoorId(doorCabinet.getHardDoorId());
dto.setCabinetNo(doorCabinet.getCabinetNo());
HardSpuJoinEntity cabinetSpu = hardSpuJoinService.getOne(new LambdaQueryWrapper<HardSpuJoinEntity>()
.eq(HardSpuJoinEntity::getHardDoorId, dto.getHardDoorId())
.eq(HardSpuJoinEntity::getCabinetNo, dto.getCabinetNo())
.eq(HardSpuJoinEntity::getSpuId, dto.getSpuId())
);
if (ObjectUtil.isEmpty(cabinetSpu)) {
throw new RuntimeException("货柜中没有这个商品");
}
Integer beforeCount = 0;
if (ObjectUtil.isNotEmpty(spuDetail.getRepertoryCount())) {
beforeCount = spuDetail.getRepertoryCount();
}
entity.setBeforeCount(beforeCount);
entity.setUserId(user.getId());
entity.setBizType(HardSpuRepertoryTypeEnum.HANDLER.getType());
baseMapper.insert(entity);
// 更新商品库存
dto.setBeforeCount(beforeCount);
dto.setUserId(user.getId());
dto.setBizType(HardSpuRepertoryTypeEnum.HANDLER.getType());
baseMapper.insert(dto);
// 更新商品总库存
HardSpuEntity spu = new HardSpuEntity();
spu.setId(spuDetail.getId());
spu.setRepertoryCount(entity.getCount() + beforeCount);
spu.setRepertoryCount(dto.getCount() + beforeCount);
spu.setVersion(spuDetail.getVersion());
hardSpuService.updateById(spu);
return entity.getId();
// 更新柜门商品库存
HardSpuJoinEntity cabinetSpuJoin = new HardSpuJoinEntity();
cabinetSpuJoin.setId(cabinetSpu.getId());
cabinetSpuJoin.setVersion(cabinetSpu.getVersion());
cabinetSpuJoin.setRepertoryCount(dto.getCount() + cabinetSpu.getRepertoryCount());
hardSpuJoinService.updateById(cabinetSpuJoin);
return dto.getId();
}
/**
@@ -169,9 +193,13 @@ public class HardSpuRepertoryServiceImpl extends ServiceImpl<HardSpuRepertoryMap
// 查询商品列表
List<Long> spuIds = list.stream().map(DeductionSpuRepertoryDto.Item::getHardSpuId).toList();
List<HardSpuEntity> spuList = hardSpuService.listByIds(spuIds);
// 查询货柜商品列表
List<HardSpuJoinEntity> spuJoinList = hardSpuJoinService.list(new LambdaQueryWrapper<HardSpuJoinEntity>()
.in(HardSpuJoinEntity::getSpuId, spuIds)
.eq(HardSpuJoinEntity::getHardDoorId, hardDoorFlow.getHardDoorId())
.eq(HardSpuJoinEntity::getCabinetNo, hardDoorFlow.getCabinetNo())
);
// 更新上架记录
List<HardSpuRepertoryEntity> spuRepertoryList = new ArrayList<>();
List<HardSpuEntity> spuUpdateList = new ArrayList<>();
for (DeductionSpuRepertoryDto.Item i : list) {
spuList.stream().filter(v -> v.getId().equals(i.getHardSpuId())).findFirst().ifPresent(spu -> {
HardSpuRepertoryEntity entity = new HardSpuRepertoryEntity();
@@ -179,24 +207,31 @@ public class HardSpuRepertoryServiceImpl extends ServiceImpl<HardSpuRepertoryMap
if (ObjectUtil.isNotEmpty(spu.getRepertoryCount())) {
beforeCount = spu.getRepertoryCount();
}
entity.setHardDoorId(hardDoorFlow.getHardDoorId());
entity.setCabinetNo(hardDoorFlow.getCabinetNo());
entity.setSpuId(spu.getId());
entity.setUserId(userId);
entity.setBeforeCount(beforeCount);
entity.setCount(i.getPlusCount() + beforeCount);
entity.setCount(i.getPlusCount());
entity.setBizId(body.getFlowId());
entity.setBizType(HardSpuRepertoryTypeEnum.PERSION.getType());
spuRepertoryList.add(entity);
baseMapper.insert(entity);
// 更新总商品库存
HardSpuEntity spuEntity = new HardSpuEntity();
spuEntity.setId(spu.getId());
spuEntity.setRepertoryCount(entity.getCount());
spuUpdateList.add(spuEntity);
spuEntity.setVersion(spu.getVersion());
spuEntity.setRepertoryCount(entity.getCount() + beforeCount);
hardSpuService.updateById(spuEntity);
// 更新货柜商品库存
spuJoinList.stream().filter(v -> ObjectUtil.equals(v.getSpuId(), spu.getId())).findFirst().ifPresent(spuJoin -> {
HardSpuJoinEntity spuJoinEntity = new HardSpuJoinEntity();
spuJoinEntity.setId(spuJoin.getId());
spuJoinEntity.setVersion(spuJoin.getVersion());
spuJoinEntity.setRepertoryCount(entity.getCount() + spuJoin.getRepertoryCount());
hardSpuJoinService.updateById(spuJoinEntity);
});
});
}
// 添加上架记录
baseMapper.insert(spuRepertoryList);
// 更新商品库存
hardSpuService.updateBatchById(spuUpdateList);
return false;
}
@@ -15,6 +15,7 @@ import com.bsd.pjcloud.hard.api.dto.spu.DeductionSpuStockDto;
import com.bsd.pjcloud.hard.api.dto.spu.HardPutawayDto;
import com.bsd.pjcloud.hard.api.dto.spu.HardSpuDto;
import com.bsd.pjcloud.hard.api.dto.spu.HardSpuJoinDto;
import com.bsd.pjcloud.hard.api.entity.HardDoorFlowEntity;
import com.bsd.pjcloud.hard.api.entity.spu.HardSpuEntity;
import com.bsd.pjcloud.hard.api.entity.spu.HardSpuJoinEntity;
import com.bsd.pjcloud.hard.api.vo.manager.HardDoorManagerVo;
@@ -121,9 +122,9 @@ public class HardSpuServiceImpl extends ServiceImpl<HardSpuMapper, HardSpuEntity
public List<Map<Integer, List<HardSpuJoinVo>>> getByCabinetNo(Long hardId, String cabinetNo) {
List<Map<Integer, List<HardSpuJoinVo>>> result = new LinkedList<>();
// 查询设备
HardDoorManagerVo doorManagerVo = hardDoorManagerService.getByHardDoorId(hardId);
HardDoorManagerVo doorManagerVo = hardDoorManagerService.getByHardId(hardId);
if (ObjectUtil.isEmpty(doorManagerVo)) return result;
int doorCount = 6;
int doorCount = 5;
int storeySpuMaxCount = 10;
if (ObjectUtil.isNotEmpty(doorCount)) {
doorCount = doorManagerVo.getDoorCount().intValue();
@@ -184,10 +185,11 @@ public class HardSpuServiceImpl extends ServiceImpl<HardSpuMapper, HardSpuEntity
HardSpuEntity spuDetail = validateSpu(dto.getHardSpuId());
// 判断这一层是否重复
long doorCount = hardSpuJoinService.count(new LambdaUpdateWrapper<HardSpuJoinEntity>()
.eq(HardSpuJoinEntity::getHardDoorNumber, spuJoinDetail.getHardDoorNumber())
.eq(HardSpuJoinEntity::getHardDoorId, spuJoinDetail.getHardDoorId())
.eq(HardSpuJoinEntity::getCabinetNo, spuJoinDetail.getCabinetNo())
.eq(HardSpuJoinEntity::getSpuId, spuDetail.getId())
);
if (doorCount > 0) throw new RuntimeException("该层已有相同商品");
if (doorCount > 0) throw new RuntimeException("该货柜已有相同商品");
LambdaUpdateWrapper<HardSpuJoinEntity> updateObj = new LambdaUpdateWrapper<HardSpuJoinEntity>()
.set(HardSpuJoinEntity::getSpuId, spuDetail.getId())
.eq(HardSpuJoinEntity::getId, dto.getId());
@@ -240,8 +242,8 @@ public class HardSpuServiceImpl extends ServiceImpl<HardSpuMapper, HardSpuEntity
if (ObjectUtil.equals(spuDetail.getPrice(), 0)) {
throw new RuntimeException("商品价格不能为0");
}
if (spuDetail.getRepertoryCount() <= 0) {
throw new RuntimeException("商品库存不能小于0");
if (ObjectUtil.isEmpty(spuDetail.getSpuCategoryId())) {
throw new RuntimeException("请编辑商品分类");
}
return spuDetail;
}
@@ -251,7 +253,11 @@ public class HardSpuServiceImpl extends ServiceImpl<HardSpuMapper, HardSpuEntity
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean deductionSpuStock(List<DeductionSpuStockDto> list) {
public Boolean deductionSpuStock(HardDoorFlowEntity hardDoorFlow, List<DeductionSpuStockDto> list) {
if (ObjectUtil.isEmpty(hardDoorFlow)) {
log.error("|{}|扣减商品库存失败flow为空dto|{}|", TAG, JSONUtil.toJsonStr(list));
return false;
}
if (ObjectUtil.isEmpty(list)) {
log.error("|{}|扣减商品库存失败list为空", TAG);
return false;
@@ -262,6 +268,12 @@ public class HardSpuServiceImpl extends ServiceImpl<HardSpuMapper, HardSpuEntity
log.error("|{}|扣减商品库存失败查询到的智能柜商品为空dto|{}|", TAG, JSONUtil.toJsonStr(list));
return false;
}
// 查询货柜商品
List<HardSpuJoinEntity> hardSpuJoinList = hardSpuJoinService.list(new LambdaQueryWrapper<HardSpuJoinEntity>()
.in(HardSpuJoinEntity::getSpuId, hardSpuIdes)
.eq(HardSpuJoinEntity::getHardDoorId, hardDoorFlow.getHardDoorId())
.eq(HardSpuJoinEntity::getCabinetNo, hardDoorFlow.getCabinetNo())
);
for (HardSpuEntity i : hardSpuList) {
list.stream().filter(j -> ObjectUtil.equals(i.getId(), j.getHardSpuId())).findFirst().ifPresent(hardSpu -> {
if (ObjectUtil.isNotEmpty(hardSpu.getIncrCount())) {
@@ -269,11 +281,22 @@ public class HardSpuServiceImpl extends ServiceImpl<HardSpuMapper, HardSpuEntity
entity.setId(hardSpu.getHardSpuId());
entity.setSalesCount(i.getSalesCount() + hardSpu.getIncrCount());
entity.setRepertoryCount(i.getRepertoryCount() - hardSpu.getIncrCount());
entity.setVersion(i.getVersion());
// 乐观锁循环扣减库存
baseMapper.updateById(entity);
}
});
}
for (HardSpuJoinEntity i : hardSpuJoinList) {
// 更新货柜商品库存
list.stream().filter(v -> ObjectUtil.equals(v.getHardSpuId(), i.getSpuId())).findFirst().ifPresent(spu -> {
HardSpuJoinEntity spuJoinEntity = new HardSpuJoinEntity();
spuJoinEntity.setId(i.getId());
spuJoinEntity.setVersion(i.getVersion());
spuJoinEntity.setRepertoryCount(i.getRepertoryCount() - spu.getIncrCount());
hardSpuJoinService.updateById(spuJoinEntity);
});
}
return true;
}
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bsd.pjcloud.hard.mapper.HardApptMapper">
<resultMap id="hardApptMap" type="com.bsd.pjcloud.hard.api.entity.HardApptEntity">
<id property="id" column="id"/>
<result property="title" column="title"/>
<result property="startTime" column="start_time"/>
<result property="endTime" column="end_time"/>
<result property="status" column="status"/>
<result property="remark" column="remark"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="delFlag" column="del_flag"/>
<result property="tenantId" column="tenant_id"/>
</resultMap>
</mapper>
@@ -2,8 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bsd.pjcloud.hard.mapper.manager.HardDoorCabinetMapper">
<resultMap id="hardDoorCabinetMap" type="com.bsd.pjcloud.hard.api.entity.manager.HardDoorCabinetEntity">
<resultMap id="hardDoorCabinetMap" type="com.bsd.pjcloud.hard.api.entity.manager.HardDoorCabinetEntity">
<id property="id" column="id"/>
<result property="hardDoorId" column="hard_door_id"/>
<result property="cabinetNo" column="cabinet_no"/>
@@ -18,5 +17,47 @@
<result property="updateTime" column="update_time"/>
<result property="delFlag" column="del_flag"/>
<result property="tenantId" column="tenant_id"/>
</resultMap>
</resultMap>
<sql id="selectA">
select a.id,
a.hard_door_id,
a.cabinet_no,
a.is_lock_online,
a.lock_status,
a.door_status,
a.sale_status,
a.qr_code,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
a.del_flag,
a.tenant_id,
</sql>
<sql id="whereA">
a.del_flag = '0'
<if test="dto.hardDoorId != null">
and a.hard_door_id = #{dto.hardDoorId}
</if>
<if test="dto.cabinetNo != null">
and a.cabinet_no like concat('%', #{dto.cabinetNo}, '%')
</if>
</sql>
<select id="scopePageJoin" resultType="com.bsd.pjcloud.hard.api.vo.manager.HardDoorCabinetVo">
<include refid="selectA"/>
hardDoor.device_code,
h.id as hardId,
h.name as hardName,
h.type as hardType
from hard_door_cabinet a
inner join hard_door_manager hardDoor on hardDoor.id = a.hard_door_id
inner join hard_manager h on h.id = hardDoor.hard_id
<where>
<include refid="whereA"/>
</where>
order by a.hard_door_id asc , a.cabinet_no asc
</select>
</mapper>
@@ -94,7 +94,14 @@
order by a.create_time desc , a.id desc
</select>
<select id="pageJoin" resultType="com.bsd.pjcloud.hard.api.vo.manager.HardDoorManagerVo">
<select id="pageJoinByHardDoorId" resultType="com.bsd.pjcloud.hard.api.vo.manager.HardDoorManagerVo">
<include refid="selectPage"/>
<where>
a.id = #{hardDoorId}
</where>
</select>
<select id="pageJoinByHardId" resultType="com.bsd.pjcloud.hard.api.vo.manager.HardDoorManagerVo">
<include refid="selectPage"/>
<where>
a.hard_id = #{hardId}
@@ -240,6 +240,13 @@
</if>
</where>
group by a.merchant_id
order by
CASE a.merchant_type
WHEN 1 THEN 1
WHEN 3 THEN 2
WHEN 0 THEN 3
WHEN 2 THEN 4
ELSE 5 END
</select>
<select id="listCsByDay" resultType="com.bsd.pjcloud.hard.api.vo.order.HardOrderCsVo">
@@ -255,6 +262,16 @@
order by DATE_FORMAT(a.create_time, '%Y-%m-%d') desc, a.merchant_id desc
</select>
<select id="listCsTotal" resultType="com.bsd.pjcloud.hard.api.vo.order.HardOrderCsVo">
select a.merchant_id,
sum(a.pay_price) as totalPayPrice,
count(0) as totalPayCount
from hard_order a
<where>
<include refid="whereA"/>
</where>
</select>
<select id="listOrerPayType" resultType="com.bsd.pjcloud.hard.api.vo.order.HardOrderPayTypeVo">
select
a.pay_type,
@@ -5,6 +5,8 @@
<resultMap id="hardSpuRepertoryMap" type="com.bsd.pjcloud.hard.api.entity.spu.HardSpuRepertoryEntity">
<id property="id" column="id"/>
<result property="userId" column="user_id"/>
<result property="hardDoorId" column="hard_door_id"/>
<result property="cabinetNo" column="cabinet_no"/>
<result property="spuId" column="spu_id"/>
<result property="beforeCount" column="before_count"/>
<result property="count" column="count"/>
@@ -19,6 +21,8 @@
<sql id="selectA">
select a.id,
a.hard_door_id,
a.cabinet_no,
a.user_id,
a.spu_id,
a.before_count,
@@ -55,10 +59,16 @@
<include refid="selectA"/>
s.name as spuName,
s.spu_category_id,
c.name as spuCategoryName
c.name as spuCategoryName,
hardD.device_code,
m.id as hardId,
m.name as hardName,
m.type as hardType
from hard_spu_repertory a
left join hard_spu s on s.id = a.spu_id
left join hard_spu_category c on c.id = s.spu_category_id
left join hard_door_manager hardD on hardD.id = a.hard_door_id
left join hard_manager m on m.id = hardD.hard_id
<where>
<include refid="whereA"/>
</where>
@@ -5,6 +5,7 @@ import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.feign.annotation.NoToken;
import com.bsd.pjcloud.mqtt.dto.MqttBaseDto;
import com.bsd.pjcloud.mqtt.dto.hard.HardPrintMsg;
import com.bsd.pjcloud.mqtt.dto.hard.HardTakeFoodBroadcastMsg;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@@ -63,9 +64,16 @@ public interface RemoteMqttEventService {
R<Boolean> sendFaceChangeMsg(@RequestParam Long userDeptId, @RequestParam Long userId, @RequestParam(required = false) Boolean isGlobalFace);
/**
* 人脸变化
* 打印机
*/
@NoToken
@PostMapping("/mqtt/send-print")
R<Boolean> sendPrint(@RequestBody HardPrintMsg dto);
/**
* 订餐广播
*/
@NoToken
@PostMapping("/mqtt/send-take-food-broadcast")
R<Boolean> sendTakeFoodBroadcast(@RequestBody HardTakeFoodBroadcastMsg dto);
}
@@ -16,6 +16,7 @@ public enum MqttActionEnum {
SUPERMARKET_CLASSIFY("超市分类变化"),
PRINT("打印变化"),
FACE("人脸变化"),
TAKE_FOOD_BROADCAST("定餐广播"),
;
private final String description;
}
@@ -0,0 +1,59 @@
package com.bsd.pjcloud.mqtt.dto.hard;
import com.bsd.pjcloud.mqtt.dto.MqttHardBaseMsg;
import lombok.Data;
@Data
public class HardTakeFoodBroadcastMsg extends MqttHardBaseMsg {
/**
* 发送硬件的topic
*/
private String topic;
/**
* 预定用户id
*/
private String userId;
/**
* 预定用户名
*/
private String userName;
/**
* 预定用户手机号
*/
private String userMobile;
/**
* 广播id
*/
private String id;
/**
* 预定标题
*/
private String title;
/**
* 广播内容
*/
private String content;
/**
* 最大广播次数
*/
private Integer broadcastMaxCount;
/**
* 商品介绍
*/
private String productDesc;
/**
* 支付价格
*/
private Integer payPrice;
}
@@ -1,74 +0,0 @@
package com.bsd.pjcloud.mqtt.broadcast;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
/**
* 硬件语音广播
*/
@Service
@Slf4j
public class BroadcastVideoService {
private ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
// 用于管理定时任务
private ScheduledFuture<?> scheduledFuture;
// 用于管理自动停止任务
private ScheduledFuture<?> autoStopFuture;
private final int interval = 60;
private final int autoInterval = 60 * 5;
/**
* 启动广播
*/
public void startBroadcast() {
if (scheduledFuture == null || scheduledFuture.isDone()) {
scheduledFuture = executorService.scheduleAtFixedRate(() -> {
playAudio();
}, 0, interval, TimeUnit.SECONDS);
log.info("广播已启动");
startAutoStopTask();
}
}
/**
* 停止广播
*/
public void stopBroadcast() {
if (scheduledFuture == null) return;
scheduledFuture.cancel(false);
scheduledFuture = null;
if (autoStopFuture != null) {
autoStopFuture.cancel(false);
autoStopFuture = null;
}
log.info("广播已停止");
}
/**
* 自动关闭广播任务
*/
private void startAutoStopTask() {
autoStopFuture = executorService.schedule(() -> {
if (scheduledFuture != null && !scheduledFuture.isDone()) {
log.info("{}秒内未收到消息,自动停止广播", autoInterval);
stopBroadcast();
}
}, autoInterval, TimeUnit.MINUTES);
}
/**
* 播放音频
*/
private void playAudio() {
}
}
@@ -7,6 +7,7 @@ import com.bsd.pjcloud.mqtt.constant.MqttActionEnum;
import com.bsd.pjcloud.mqtt.dto.MqttBaseDto;
import com.bsd.pjcloud.mqtt.dto.hard.HardCustomerMsg;
import com.bsd.pjcloud.mqtt.dto.hard.HardPrintMsg;
import com.bsd.pjcloud.mqtt.dto.hard.HardTakeFoodBroadcastMsg;
import com.bsd.pjcloud.mqtt.service.MqttEventService;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -133,4 +134,15 @@ public class MqttEventController {
return R.ok(mqttEventService.defaultAction(mqttBaseDto));
}
/**
* 订餐广播
*/
@Inner
@PostMapping("/send-take-food-broadcast")
public R<Boolean> sendTakeFoodBroadcast(@RequestBody HardTakeFoodBroadcastMsg dto) {
MqttBaseDto mqttBaseDto = new MqttBaseDto();
mqttBaseDto.setAction(dto.getAction());
mqttBaseDto.setData(dto);
return R.ok(mqttEventService.sendTakeFoodBroadcast(mqttBaseDto, dto.getTopic()));
}
}
@@ -39,4 +39,20 @@ public class MqttEventService {
}
dto.setHardGroupId(dept.getHardGroupId());
}
/**
* 订餐广播
*/
public Boolean sendTakeFoodBroadcast(MqttBaseDto dto, String topic) {
try {
MqttHardBaseMsg msg = dto.getData();
if (ObjectUtil.isEmpty(msg)) msg = new MqttHardBaseMsg();
msg.setAction(dto.getAction());
mqttService.publish(dto.getQos(), false, topic, JSON.toJSONString(msg));
return true;
} catch (Exception e) {
log.error("|{}|发送订餐广播失败dto:|{}|", TAG, JSON.toJSONString(dto), e);
return false;
}
}
}
@@ -85,25 +85,28 @@ public class ThirdDoorApiController {
@Inner(value = false)
@Operation(summary = "门锁开关通知回调")
@PostMapping("/callback/open")
public void callbackOpen(HttpEntity<String> httpEntity, @RequestHeader Map<String, String> headers) {
public R callbackOpen(HttpEntity<String> httpEntity, @RequestHeader Map<String, String> headers) {
String body = httpEntity.getBody();
thirdDoorApiService.callbackOpen(body, headers);
return R.ok();
}
@Inner(value = false)
@Operation(summary = "视频地址通知回调")
@PostMapping("/callback/video")
public void callbackVideo(HttpEntity<String> httpEntity, @RequestHeader Map<String, String> headers) {
public R callbackVideo(HttpEntity<String> httpEntity, @RequestHeader Map<String, String> headers) {
String body = httpEntity.getBody();
thirdDoorApiService.callbackVideo(body, headers);
return R.ok();
}
@Inner(value = false)
@Operation(summary = "设备状态通知回调")
@PostMapping("/callback/status")
public void callbackStatus(HttpEntity<String> httpEntity, @RequestHeader Map<String, String> headers) {
public R callbackStatus(HttpEntity<String> httpEntity, @RequestHeader Map<String, String> headers) {
String body = httpEntity.getBody();
thirdDoorApiService.callbackStatus(body, headers);
return R.ok();
}
@@ -105,17 +105,19 @@ public class ThirdKsApiController {
@Inner(value = false)
@Operation(summary = "sku审核回调")
@PostMapping("/callback/sku")
public void callbackSKu(HttpEntity<String> httpEntity, @RequestHeader Map<String, String> headers) {
public R callbackSKu(HttpEntity<String> httpEntity, @RequestHeader Map<String, String> headers) {
String body = httpEntity.getBody();
thirdKsApiService.callbackSKu(body, headers);
return R.ok();
}
@Inner(value = false)
@Operation(summary = "识别回调")
@PostMapping("/callback/recognition")
public void callbackRecognition(HttpEntity<String> httpEntity, @RequestHeader Map<String, String> headers) {
public R callbackRecognition(HttpEntity<String> httpEntity, @RequestHeader Map<String, String> headers) {
String body = httpEntity.getBody();
thirdKsApiService.callbackRecognition(body, headers);
return R.ok();
}
/* ************************************* end 回调 end ************************************* */
@@ -213,10 +213,10 @@ public class ThirdDoorApiServiceImpl implements ThirdDoorApiService {
DoorBaseVo doorBaseVo = new DoorBaseVo();
DoorApi.Api api = DoorApi.OPEN.setBaseUrl(doorConfig.getBaseUrl());
ThirdDoorLogEntity logEntity = api.getInitLogEntity();
logEntity.setReq(JSONUtil.toJsonStr(dto));
try {
dto.setLockNotifyUrl(doorConfig.getCallbackBaseUrl() + doorConfig.getCallbackLockUrl());
dto.setVideoNotifyUrl(doorConfig.getCallbackBaseUrl() + doorConfig.getCallbackVideoUrl());
logEntity.setReq(JSONUtil.toJsonStr(dto));
String body = JSONUtil.toJsonStr(dto);
String res = api.getHttpRequest().header(apiCountersign(body)).body(body).execute().body();
if (ObjectUtil.isEmpty(res)) throw new RuntimeException("response响应为空");
@@ -387,12 +387,13 @@ public class ThirdDoorApiServiceImpl implements ThirdDoorApiService {
log.error("|{}|apiParseSign 接口解签错误headers为空dto|{}|headers|{}|", TAG, json, JSONUtil.toJsonStr(headers));
return false;
}
String appid = headers.get("Appid");
String noncestr = headers.get("Noncestr");
String timestamp = headers.get("Timestamp");
String sign = headers.get("Sign");
String appid = headers.get("appId");
String noncestr = headers.get("nonceStr");
String timestamp = headers.get("timestamp");
String sign = headers.get("sign");
if (ObjectUtil.notEqual(doorConfig.getAppId(), appid)) {
log.error("|{}|apiParseSign 接口解签错误appId错误dto|{}|headers|{}|", TAG, json, JSONUtil.toJsonStr(headers));
log.error("|{}|apiParseSign 接口解签错误appId错误dto|{}|headers|{}|appid|{}|nonceStr|{}|timestamp|{}|sign|{}|", TAG, json, JSONUtil.toJsonStr(headers), appid, noncestr, timestamp, sign);
return false;
}
// 计算正确的sign
@@ -404,7 +405,7 @@ public class ThirdDoorApiServiceImpl implements ThirdDoorApiService {
successSign += json;
String successSignMd5 = DigestUtils.md5Hex(successSign);
if (ObjectUtil.notEqual(successSignMd5.toLowerCase(), sign.toLowerCase())) {
log.error("|{}|apiParseSign 接口解签错误sign错误dto|{}|headers|{}|", TAG, json, JSONUtil.toJsonStr(headers));
log.error("|{}|apiParseSign 接口解签错误sign错误dto|{}|headers|{}|appid|{}|nonceStr|{}|timestamp|{}|sign|{}|", TAG, json, JSONUtil.toJsonStr(headers), appid, noncestr, timestamp, sign);
return false;
}
return true;
@@ -71,23 +71,23 @@ zy:
# self_token_secret: eV3dT0oD7iX8rK4eC3jS6fU8cU5cS6mJ
# 智能柜
door:
base-url: https://www.365e-life.net:8443/bkopenapi
app-id: 2025040991646569
app-key: 2800650617d44e0d8b31ad5287431179
callback-base-url: http://h1yzkslmyx.ny.takin.cc
callback-lock-url: /third/third-door/callback/open
callback-video-url: /third/third-door/callback/video
# door:
# base-url: https://www.365e-life.net:8443/bkopenapi
# app-id: 2025040991646569
# app-key: 2800650617d44e0d8b31ad5287431179
# callback-base-url: http://h1yzkslmyx.ny.takin.cc
# callback-lock-url: /third/third-door/callback/open
# callback-video-url: /third/third-door/callback/video
# 旷世识别
ks-discern:
base-url: https://retail.xlsdn.com
access-key: ed5A923eF0e941A1968eGTpF
secret-key: Ex3X0kgoc94sBOtivjWm5Vz9AyZTOUpl
host: retail.xlsdn.com
callback-base-url: http://h1yzkslmyx.ny.takin.cc
callback-recognition-url: /third/third-ks/callback/recognition
callback-sku-url: /third/third-ks/callback/sku
# ks-discern:
# base-url: https://retail.xlsdn.com
# access-key: ed5A923eF0e941A1968eGTpF
# secret-key: Ex3X0kgoc94sBOtivjWm5Vz9AyZTOUpl
# host: retail.xlsdn.com
# callback-base-url: http://h1yzkslmyx.ny.takin.cc
# callback-recognition-url: /third/third-ks/callback/recognition
# callback-sku-url: /third/third-ks/callback/sku
@@ -0,0 +1,17 @@
package com.bsd.pjcloud.admin.api.dto;
import com.bsd.pjcloud.admin.api.entity.SysUserTransactionEntity;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public class SysUserTransactionDto extends SysUserTransactionEntity {
private LocalDateTime[] createTimeList;
private LocalDateTime[] walletTransactionTimeList;
private LocalDateTime[] processTimeList;
}
@@ -0,0 +1,130 @@
package com.bsd.pjcloud.admin.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 com.bsd.pjcloud.common.core.util.TenantTable;
import java.time.LocalDateTime;
/**
* 人员调动表
*/
@Data
@TenantTable
@TableName("sys_user_transaction")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "人员调动表")
public class SysUserTransactionEntity extends Model<SysUserTransactionEntity> {
/**
* 编号
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description="编号")
private Long id;
/**
* 用户id
*/
@Schema(description="用户id")
private Long userId;
/**
* 业务id
*/
@Schema(description="业务id")
private Long bizId;
/**
* 业务类型
*/
@Schema(description="业务类型")
private String bizType;
/**
* 源部门id
*/
@Schema(description="源部门id")
private Long sourceDeptId;
/**
* 目标部门id
*/
@Schema(description="目标部门id")
private Long targetDeptId;
/**
* 是否离职自动转账
*/
@Schema(description="是否离职自动转账")
private String isWalletTransaction;
/**
* 离职自动转账时间
*/
@Schema(description="离职自动转账时间")
private LocalDateTime walletTransactionTime;
/**
* 流程id
*/
@Schema(description="流程id")
private String processId;
/**
* 审核状体
*/
@Schema(description="审核状体")
private String processStatus;
/**
* 审核时间
*/
@Schema(description="审核时间")
private LocalDateTime processTime;
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建人")
private String createBy;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建时间")
private LocalDateTime createTime;
/**
* 修改人
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="修改人")
private String updateBy;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="修改时间")
private LocalDateTime updateTime;
/**
* 删除标记
*/
@TableLogic
@TableField(fill = FieldFill.INSERT)
@Schema(description="删除标记")
private String delFlag;
/**
* 租户ID
*/
@Schema(description="租户ID")
private Long tenantId;
}
@@ -0,0 +1,18 @@
package com.bsd.pjcloud.admin.api.vo;
import lombok.Data;
@Data
public class RoleAppUserRoleVo {
/**
* 是否是商家
*/
private Boolean isMch = false;
/**
* 是否是智能柜管理员
*/
private Boolean isHardDoorAdmin = false;
}
@@ -0,0 +1,29 @@
package com.bsd.pjcloud.admin.api.vo;
import com.bsd.pjcloud.admin.api.entity.SysUserTransactionEntity;
import com.bsd.pjcloud.admin.api.vo.base.BaseUserInterface;
import lombok.Data;
@Data
public class SysUserTransactionVo extends SysUserTransactionEntity implements BaseUserInterface {
/**
* 源部门名称
*/
private String sourceDeptName;
/**
* 目标部门名称
*/
private String targetDeptName;
/**
* 用户相关
*/
private String username;
private String userMobile;
private String userAvatar;
}
@@ -20,31 +20,31 @@
package com.bsd.pjcloud.admin.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.admin.api.entity.SysRole;
import com.bsd.pjcloud.admin.api.entity.SysUser;
import com.bsd.pjcloud.admin.api.entity.SysUserRole;
import com.bsd.pjcloud.admin.api.vo.RoleAppUserRoleVo;
import com.bsd.pjcloud.admin.api.vo.RoleExcelVO;
import com.bsd.pjcloud.admin.api.vo.RoleMenuVO;
import com.bsd.pjcloud.admin.service.SysRoleService;
import com.bsd.pjcloud.admin.service.SysUserRoleService;
import com.bsd.pjcloud.common.core.constant.CacheConstants;
import com.bsd.pjcloud.common.core.exception.ErrorCodes;
import com.bsd.pjcloud.common.core.util.MsgUtils;
import com.bsd.pjcloud.common.core.constant.CommonRoleConstant;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.excel.annotation.RequestExcel;
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.common.security.annotation.HasPermission;
import com.bsd.pjcloud.common.security.annotation.Inner;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
import com.bsd.pjcloud.common.security.util.SecurityUtils;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.http.HttpHeaders;
@@ -66,153 +66,192 @@ import java.util.stream.Collectors;
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class SysRoleController {
private final SysRoleService sysRoleService;
private final SysRoleService sysRoleService;
private final SysUserRoleService sysUserRoleService;
private final SysUserRoleService sysUserRoleService;
@Inner
@PostMapping("/by-codes")
public R<List<SysRole>> findRolesByCodes(@RequestBody List<String> codes) {
return R.ok(sysRoleService.findRolesByCodes(codes));
}
/* ************************************* start 数据同步 start ************************************* */
/**
* 通过ID查询角色信息
* @param id ID
* @return 角色信息
*/
@GetMapping("/details/{id}")
public R getById(@PathVariable Long id) {
return R.ok(sysRoleService.getById(id));
}
/**
* 判断用户移动端角色
*/
@GetMapping("/app/user-role")
public R<RoleAppUserRoleVo> userRole() {
PjcloudUser user = SecurityUtils.getUser();
RoleAppUserRoleVo result = new RoleAppUserRoleVo();
List<SysRole> roleList = sysRoleService.findRolesByUserId(user.getId());
if (ObjectUtil.isEmpty(roleList)) {
R.ok(result);
}
for (SysRole v : roleList) {
if (ObjectUtil.equals(v.getRoleCode(), CommonRoleConstant.MCH_USER)) {
result.setIsMch(true);
}
if (ObjectUtil.equals(v.getRoleCode(), CommonRoleConstant.HARD_DOOR_ADMIN_USER)) {
result.setIsHardDoorAdmin(true);
}
}
return R.ok(result);
}
/**
* 查询角色信息
* @param query 查询条件
* @return 角色信息
*/
@GetMapping("/details")
public R getDetails(@ParameterObject SysRole query) {
return R.ok(sysRoleService.getOne(Wrappers.query(query), false));
}
/**
* 添加角色
* @param sysRole 角色信息
* @return success、false
*/
@SysLog("添加角色")
@PostMapping
@HasPermission("sys_role_add")
@CacheEvict(value = CacheConstants.ROLE_DETAILS, allEntries = true)
public R save(@Valid @RequestBody SysRole sysRole) {
return R.ok(sysRoleService.save(sysRole));
}
/* ************************************* end 数据同步 end ************************************* */
/**
* 修改角色
* @param sysRole 角色信息
* @return success/false
*/
@SysLog("修改角色")
@PutMapping
@HasPermission("sys_role_edit")
@CacheEvict(value = CacheConstants.ROLE_DETAILS, allEntries = true)
public R update(@Valid @RequestBody SysRole sysRole) {
return R.ok(sysRoleService.updateById(sysRole));
}
@Inner
@PostMapping("/by-codes")
public R<List<SysRole>> findRolesByCodes(@RequestBody List<String> codes) {
return R.ok(sysRoleService.findRolesByCodes(codes));
}
/**
* 删除角色
* @param ids
* @return
*/
@SysLog("删除角色")
@DeleteMapping
@HasPermission("sys_role_del")
@CacheEvict(value = CacheConstants.ROLE_DETAILS, allEntries = true)
public R removeById(@RequestBody Long[] ids) {
return R.ok(sysRoleService.removeRoleByIds(ids));
}
/**
* 通过ID查询角色信息
*
* @param id ID
* @return 角色信息
*/
@GetMapping("/details/{id}")
public R getById(@PathVariable Long id) {
return R.ok(sysRoleService.getById(id));
}
/**
* 获取角色列表
* @return 角色列表
*/
@GetMapping("/list")
public R listRoles() {
return R.ok(sysRoleService.list(Wrappers.emptyWrapper()));
}
/**
* 查询角色信息
*
* @param query 查询条件
* @return 角色信息
*/
@GetMapping("/details")
public R getDetails(@ParameterObject SysRole query) {
return R.ok(sysRoleService.getOne(Wrappers.query(query), false));
}
@GetMapping("/isMchUser")
public R<Boolean> isMchUser() {
Long id = SecurityUtils.getUser().getId();
List<SysUserRole> sysUserRoles = sysUserRoleService.list(Wrappers.<SysUserRole>lambdaQuery().eq(SysUserRole::getUserId, id));
List<Long> roleIds = sysUserRoles.stream().map(sysUserRole -> sysUserRole.getRoleId()).collect(Collectors.toList());
List<SysRole> list = sysRoleService.list(Wrappers.<SysRole>lambdaQuery().eq(SysRole::getRoleCode, "MCH_USER"));
if (CollectionUtils.isEmpty(list) || CollUtil.isEmpty(roleIds) || !roleIds.contains(list.get(0).getRoleId())){
return R.ok(false);
}
/**
* 添加角色
*
* @param sysRole 角色信息
* @return success、false
*/
@SysLog("添加角色")
@PostMapping
@HasPermission("sys_role_add")
@CacheEvict(value = CacheConstants.ROLE_DETAILS, allEntries = true)
public R save(@Valid @RequestBody SysRole sysRole) {
return R.ok(sysRoleService.save(sysRole));
}
return R.ok(true);
}
/**
* 分页查询角色信息
* @param page 分页对象
* @param role 查询条件
* @return 分页对象
*/
@GetMapping("/page")
public R getRolePage(Page page, SysRole role) {
return R.ok(sysRoleService.page(page, Wrappers.<SysRole>lambdaQuery()
.like(StrUtil.isNotBlank(role.getRoleName()), SysRole::getRoleName, role.getRoleName())));
}
/**
* 修改角色
*
* @param sysRole 角色信息
* @return success/false
*/
@SysLog("修改角色")
@PutMapping
@HasPermission("sys_role_edit")
@CacheEvict(value = CacheConstants.ROLE_DETAILS, allEntries = true)
public R update(@Valid @RequestBody SysRole sysRole) {
return R.ok(sysRoleService.updateById(sysRole));
}
/**
* 更新角色菜单
* @param roleVo 角色对象
* @return success、false
*/
@SysLog("更新角色菜单")
@PutMapping("/menu")
@HasPermission("sys_role_perm")
public R saveRoleMenus(@RequestBody RoleMenuVO roleVo) {
return R.ok(sysRoleService.updateRoleMenus(roleVo));
}
/**
* 删除角色
*
* @param ids
* @return
*/
@SysLog("删除角色")
@DeleteMapping
@HasPermission("sys_role_del")
@CacheEvict(value = CacheConstants.ROLE_DETAILS, allEntries = true)
public R removeById(@RequestBody Long[] ids) {
return R.ok(sysRoleService.removeRoleByIds(ids));
}
/**
* 通过角色ID 查询角色列表
* @param roleIdList 角色ID
* @return
*/
@PostMapping("/getRoleList")
public R getRoleList(@RequestBody List<Long> roleIdList) {
return R.ok(sysRoleService.findRolesByRoleIds(roleIdList, CollUtil.join(roleIdList, StrUtil.UNDERLINE)));
}
/**
* 获取角色列表
*
* @return 角色列表
*/
@GetMapping("/list")
public R listRoles() {
return R.ok(sysRoleService.list(Wrappers.emptyWrapper()));
}
/**
* 导出excel 表格
* @param sysRole 查询条件
* @param ids 导出ids
* @return
*/
@ResponseExcel
@GetMapping("/export")
@HasPermission("sys_role_export")
public List<RoleExcelVO> export(SysRole sysRole, Long[] ids) {
return sysRoleService.listRole(sysRole, ids);
}
@GetMapping("/isMchUser")
public R<Boolean> isMchUser() {
Long id = SecurityUtils.getUser().getId();
List<SysUserRole> sysUserRoles = sysUserRoleService.list(Wrappers.<SysUserRole>lambdaQuery().eq(SysUserRole::getUserId, id));
List<Long> roleIds = sysUserRoles.stream().map(sysUserRole -> sysUserRole.getRoleId()).collect(Collectors.toList());
List<SysRole> list = sysRoleService.list(Wrappers.<SysRole>lambdaQuery().eq(SysRole::getRoleCode, "MCH_USER"));
if (CollectionUtils.isEmpty(list) || CollUtil.isEmpty(roleIds) || !roleIds.contains(list.get(0).getRoleId())) {
return R.ok(false);
}
return R.ok(true);
}
/**
* 导入角色
* @param excelVOList 角色列表
* @param bindingResult 错误信息列表
* @return ok fail
*/
@PostMapping("/import")
@HasPermission("sys_role_export")
public R importRole(@RequestExcel List<RoleExcelVO> excelVOList, BindingResult bindingResult) {
return sysRoleService.importRole(excelVOList, bindingResult);
}
/**
* 分页查询角色信息
*
* @param page 分页对象
* @param role 查询条件
* @return 分页对象
*/
@GetMapping("/page")
public R getRolePage(Page page, SysRole role) {
return R.ok(sysRoleService.page(page, Wrappers.<SysRole>lambdaQuery()
.like(StrUtil.isNotBlank(role.getRoleName()), SysRole::getRoleName, role.getRoleName())));
}
/**
* 更新角色菜单
*
* @param roleVo 角色对象
* @return success、false
*/
@SysLog("更新角色菜单")
@PutMapping("/menu")
@HasPermission("sys_role_perm")
public R saveRoleMenus(@RequestBody RoleMenuVO roleVo) {
return R.ok(sysRoleService.updateRoleMenus(roleVo));
}
/**
* 通过角色ID 查询角色列表
*
* @param roleIdList 角色ID
* @return
*/
@PostMapping("/getRoleList")
public R getRoleList(@RequestBody List<Long> roleIdList) {
return R.ok(sysRoleService.findRolesByRoleIds(roleIdList, CollUtil.join(roleIdList, StrUtil.UNDERLINE)));
}
/**
* 导出excel 表格
*
* @param sysRole 查询条件
* @param ids 导出ids
* @return
*/
@ResponseExcel
@GetMapping("/export")
@HasPermission("sys_role_export")
public List<RoleExcelVO> export(SysRole sysRole, Long[] ids) {
return sysRoleService.listRole(sysRole, ids);
}
/**
* 导入角色
*
* @param excelVOList 角色列表
* @param bindingResult 错误信息列表
* @return ok fail
*/
@PostMapping("/import")
@HasPermission("sys_role_export")
public R importRole(@RequestExcel List<RoleExcelVO> excelVOList, BindingResult bindingResult) {
return sysRoleService.importRole(excelVOList, bindingResult);
}
}
@@ -0,0 +1,92 @@
package com.bsd.pjcloud.admin.controller;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.admin.api.dto.SysUserTransactionDto;
import com.bsd.pjcloud.admin.api.entity.SysUserTransactionEntity;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.admin.service.SysUserTransactionService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Objects;
/**
* 人员调动表
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/sys-user-transaction")
@Tag(description = "sys-user-transaction", name = "人员调动表管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class SysUserTransactionController {
private final SysUserTransactionService sysUserTransactionService;
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('admin_sysUserTransaction_view')")
public R getSysUserTransactionPage(@ParameterObject Page page, @ParameterObject SysUserTransactionEntity sysUserTransaction) {
LambdaQueryWrapper<SysUserTransactionEntity> wrapper = Wrappers.lambdaQuery();
return R.ok(sysUserTransactionService.page(page, wrapper));
}
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page-join")
@PreAuthorize("@pms.hasPermission('admin_sysUserTransaction_view')")
public R pageJoin(@ParameterObject Page page, @ParameterObject SysUserTransactionDto dto) {
DataScope dataScope = new DataScope();
return R.ok(sysUserTransactionService.scopePageJoin(page, dto, dataScope));
}
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('admin_sysUserTransaction_view')")
public R getById(@PathVariable("id") Long id) {
return R.ok(sysUserTransactionService.getById(id));
}
@Operation(summary = "新增人员调动表", description = "新增人员调动表")
@SysLog("新增人员调动表")
@PostMapping
@PreAuthorize("@pms.hasPermission('admin_sysUserTransaction_add')")
public R save(@RequestBody SysUserTransactionEntity sysUserTransaction) {
return R.ok(sysUserTransactionService.save(sysUserTransaction));
}
@Operation(summary = "修改人员调动表", description = "修改人员调动表")
@SysLog("修改人员调动表")
@PutMapping
@PreAuthorize("@pms.hasPermission('admin_sysUserTransaction_edit')")
public R updateById(@RequestBody SysUserTransactionEntity sysUserTransaction) {
return R.ok(sysUserTransactionService.updateById(sysUserTransaction));
}
@Operation(summary = "通过id删除人员调动表", description = "通过id删除人员调动表")
@SysLog("通过id删除人员调动表")
@DeleteMapping
@PreAuthorize("@pms.hasPermission('admin_sysUserTransaction_del')")
public R removeById(@RequestBody Long[] ids) {
return R.ok(sysUserTransactionService.removeBatchByIds(CollUtil.toList(ids)));
}
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('admin_sysUserTransaction_export')")
public List<SysUserTransactionEntity> export(SysUserTransactionEntity sysUserTransaction, Long[] ids) {
return sysUserTransactionService.list(Wrappers.lambdaQuery(sysUserTransaction).in(ArrayUtil.isNotEmpty(ids), SysUserTransactionEntity::getId, ids));
}
}
@@ -0,0 +1,17 @@
package com.bsd.pjcloud.admin.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.admin.api.dto.SysUserTransactionDto;
import com.bsd.pjcloud.admin.api.entity.SysUserTransactionEntity;
import com.bsd.pjcloud.admin.api.vo.SysUserTransactionVo;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface SysUserTransactionMapper extends PjcloudBaseMapper<SysUserTransactionEntity> {
Page<SysUserTransactionVo> scopePageJoin(Page page, @Param("dto") SysUserTransactionDto dto, DataScope dataScope);
}
@@ -0,0 +1,13 @@
package com.bsd.pjcloud.admin.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.admin.api.dto.SysUserTransactionDto;
import com.bsd.pjcloud.admin.api.entity.SysUserTransactionEntity;
import com.bsd.pjcloud.admin.api.vo.SysUserTransactionVo;
import com.bsd.pjcloud.common.data.datascope.DataScope;
public interface SysUserTransactionService extends IService<SysUserTransactionEntity> {
Page<SysUserTransactionVo> scopePageJoin(Page page, SysUserTransactionDto dto, DataScope dataScope);
}
@@ -0,0 +1,27 @@
package com.bsd.pjcloud.admin.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.admin.api.dto.SysUserTransactionDto;
import com.bsd.pjcloud.admin.api.entity.SysUserTransactionEntity;
import com.bsd.pjcloud.admin.api.vo.SysUserTransactionVo;
import com.bsd.pjcloud.admin.mapper.SysUserTransactionMapper;
import com.bsd.pjcloud.admin.service.SysUserTransactionService;
import com.bsd.pjcloud.common.data.datascope.DataScope;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
* 人员调动表
*/
@Slf4j
@Service
@AllArgsConstructor
public class SysUserTransactionServiceImpl extends ServiceImpl<SysUserTransactionMapper, SysUserTransactionEntity> implements SysUserTransactionService {
@Override
public Page<SysUserTransactionVo> scopePageJoin(Page page, SysUserTransactionDto dto, DataScope dataScope) {
return baseMapper.scopePageJoin(page, dto, dataScope);
}
}
@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bsd.pjcloud.admin.mapper.SysUserTransactionMapper">
<resultMap id="sysUserTransactionMap" type="com.bsd.pjcloud.admin.api.entity.SysUserTransactionEntity">
<id property="id" column="id"/>
<result property="userId" column="user_id"/>
<result property="bizId" column="biz_id"/>
<result property="bizType" column="biz_type"/>
<result property="sourceDeptId" column="source_dept_id"/>
<result property="targetDeptId" column="target_dept_id"/>
<result property="isWalletTransaction" column="is_wallet_transaction"/>
<result property="walletTransactionTime" column="wallet_transaction_time"/>
<result property="processId" column="process_id"/>
<result property="processStatus" column="process_status"/>
<result property="processTime" column="process_time"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="delFlag" column="del_flag"/>
<result property="tenantId" column="tenant_id"/>
</resultMap>
<sql id="selectA">
select a.id,
a.user_id,
a.biz_id,
a.biz_type,
a.source_dept_id,
a.target_dept_id,
a.is_wallet_transaction,
a.wallet_transaction_time,
a.process_id,
a.process_status,
a.process_time,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
a.del_flag,
a.tenant_id,
</sql>
<sql id="whereA">
a.del_flag = '0'
<if test="dto.userId != null">
AND a.user_id = #{dto.userId}
</if>
<if test="dto.bizId != null">
AND a.biz_id = #{dto.bizId}
</if>
<if test="dto.bizId != null">
AND a.biz_id = #{dto.bizId}
</if>
<if test="dto.bizType != null">
AND a.biz_type = #{dto.bizType}
</if>
<if test="dto.sourceDeptId != null">
AND a.source_dept_id = #{dto.sourceDeptId}
</if>
<if test="dto.targetDeptId != null">
AND a.target_dept_id = #{dto.targetDeptId}
</if>
<if test="dto.isWalletTransaction != null">
AND a.is_wallet_transaction = #{dto.isWalletTransaction}
</if>
<if test="dto.processStatus != null">
AND a.process_status = #{dto.processStatus}
</if>
<if test="dto.createTimeList != null and dto.createTimeList.length == 2">
and a.create_time between #{dto.createTimeList[0]} and #{dto.createTimeList[1]}
</if>
<if test="dto.walletTransactionTimeList != null and dto.walletTransactionTimeList.length == 2">
and a.wallet_transaction_time between #{dto.walletTransactionTimeList[0]} and #{dto.walletTransactionTimeList[1]}
</if>
<if test="dto.processTimeList != null and dto.processTimeList.length == 2">
and a.create_time between #{dto.processTimeList[0]} and #{dto.processTimeList[1]}
</if>
</sql>
<select id="scopePageJoin" resultType="com.bsd.pjcloud.admin.api.vo.SysUserTransactionVo">
<include refid="selectA"/>
soureD.name as sourceDeptName,
targetD.name as targetDeptName,
u.username as username,
u.phone as userMobile,
u.avatar as userAvatar
from sys_user_transaction a
left join sys_dept soureD on soureD.dept_id = a.source_dept_id
left join sys_dept targetD on targetD.dept_id = a.target_dept_id
left join sys_user u on u.user_id = a.user_id
<where>
<include refid="whereA"/>
</where>
</select>
</mapper>