feat:检修开门接口

This commit is contained in:
dzc committed 2025-04-14 17:25:59 +08:00
1 parent f369039b21
commit c1485e7058
10 files changed
+372 -118

No files matched your search

+7 -4
View File
@@ -78,10 +78,13 @@ DROP TABLE IF EXISTS `hard_door_flow`;
CREATE TABLE hard_door_flow
(
id bigint NOT NULL COMMENT '编号',
order_id bigint NOT NULL COMMENT '订单编号',
auth_id bigint NOT NULL COMMENT '授权编号',
open_event_id varchar(32) NOT NULL COMMENT '开门事件编号',
open_out_open_no varchar(32) NOT NULL COMMENT '商户自定义开门请求号',
user_id bigint NOT NULL COMMENT '用户编号',
biz_type varchar(32) NOT NULL COMMENT '业务类型',
order_id bigint DEFAULT NULL COMMENT '订单编号',
auth_id bigint DEFAULT NULL COMMENT '授权编号',
open_event_id varchar(32) DEFAULT NULL COMMENT '开门事件编号',
open_out_open_no varchar(32) DEFAULT NULL COMMENT '商户自定义开门请求号',
request_open_time datetime DEFAULT NULL COMMENT '请求开门时间',
open_callback_res varchar(512) DEFAULT NULL COMMENT '开门回调结果',
open_callback_time datetime DEFAULT NULL COMMENT '开门回调时间',
video_callback_res varchar(512) DEFAULT NULL COMMENT '视频回调结果',
@@ -0,0 +1,26 @@
package com.bsd.pjcloud.hard.api.constant;
import cn.hutool.core.util.ObjectUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
/**
* 智能柜开门流程
*/
@AllArgsConstructor
@Getter
public enum HardDoorFlowEnum {
PAY_OPEN("10", "购买开门"),
REPERTORY_OPEN("20", "上架开门"),
ACCESS_OPEN("20", "检修开门"),
;
private final String type;
private final String description;
public static HardDoorFlowEnum valueOfByType(String type) {
if (ObjectUtil.isEmpty(type)) return null;
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get();
}
}
@@ -0,0 +1,33 @@
package com.bsd.pjcloud.hard.api.dto;
import com.bsd.pjcloud.hard.api.constant.HardDoorFlowEnum;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
@Data
public class HardDoorFlowOpenDto {
/**
* 柜子id
*/
@NotNull(message = "hardDoorId不能为空")
private Long hardDoorId;
/**
* 智能柜编号
*/
@NotEmpty(message = "货柜编号不能为空")
private String cabinetNo;
/**
* 开门操作类型
*/
private HardDoorFlowEnum type;
/**
* 开门用户id
*/
private Long userId;
}
@@ -3,9 +3,9 @@ package com.bsd.pjcloud.hard.api.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.*;
import com.bsd.pjcloud.common.core.util.TenantTable;
import java.time.LocalDateTime;
/**
@@ -14,6 +14,9 @@ import java.time.LocalDateTime;
* @author hard
* @date 2025-04-14 16:08:33
*/
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Data
@TenantTable
@TableName("hard_door_flow")
@@ -22,136 +25,154 @@ import java.time.LocalDateTime;
public class HardDoorFlowEntity extends Model<HardDoorFlowEntity> {
/**
* 编号
*/
/**
* 编号
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description="编号")
@Schema(description = "编号")
private Long id;
/**
* 订单编号
*/
@Schema(description="订单编号")
/**
* 用户编号
*/
@Schema(description = "用户编号")
private Long userId;
/**
* 业务类型
*/
@Schema(description = "业务类型")
private String bizType;
/**
* 订单编号
*/
@Schema(description = "订单编号")
private Long orderId;
/**
* 授权编号
*/
@Schema(description="授权编号")
/**
* 授权编号
*/
@Schema(description = "授权编号")
private Long authId;
/**
* 开门事件编号
*/
@Schema(description="开门事件编号")
/**
* 开门事件编号
*/
@Schema(description = "开门事件编号")
private String openEventId;
/**
* 商户自定义开门请求号
*/
@Schema(description="商户自定义开门请求号")
/**
* 商户自定义开门请求号
*/
@Schema(description = "商户自定义开门请求号")
private String openOutOpenNo;
/**
* 开门回调结果
*/
@Schema(description="开门回调结果")
/**
* 请求开门时间
*/
@Schema(description = "请求开门时间")
private LocalDateTime requestOpenTime;
/**
* 开门回调结果
*/
@Schema(description = "开门回调结果")
private String openCallbackRes;
/**
* 开门回调时间
*/
@Schema(description="开门回调时间")
/**
* 开门回调时间
*/
@Schema(description = "开门回调时间")
private LocalDateTime openCallbackTime;
/**
* 视频回调结果
*/
@Schema(description="视频回调结果")
/**
* 视频回调结果
*/
@Schema(description = "视频回调结果")
private String videoCallbackRes;
/**
* 视频回调时间
*/
@Schema(description="视频回调时间")
/**
* 视频回调时间
*/
@Schema(description = "视频回调时间")
private LocalDateTime videoCallbackTime;
/**
* 识别任务唯一ID,用于结果获取,重新发起售后识别
*/
@Schema(description="识别任务唯一ID,用于结果获取,重新发起售后识别")
/**
* 识别任务唯一ID,用于结果获取,重新发起售后识别
*/
@Schema(description = "识别任务唯一ID,用于结果获取,重新发起售后识别")
private String skuKsRecogId;
/**
* sku识别提交时间
*/
@Schema(description="sku识别提交时间")
/**
* sku识别提交时间
*/
@Schema(description = "sku识别提交时间")
private LocalDateTime skuSubmitTime;
/**
* sku识别回调结果
*/
@Schema(description="sku识别回调结果")
/**
* sku识别回调结果
*/
@Schema(description = "sku识别回调结果")
private String skuCallbackRes;
/**
* sku识别回调时间
*/
@Schema(description="sku识别回调时间")
/**
* sku识别回调时间
*/
@Schema(description = "sku识别回调时间")
private LocalDateTime skuCallbackTime;
/**
* sku识别主动获取结果
*/
@Schema(description="sku识别主动获取结果")
/**
* sku识别主动获取结果
*/
@Schema(description = "sku识别主动获取结果")
private String skuDrivingRes;
/**
* sku识别主动获取时间
*/
@Schema(description="sku识别主动获取时间")
/**
* sku识别主动获取时间
*/
@Schema(description = "sku识别主动获取时间")
private LocalDateTime skuDrivingTime;
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建人")
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description = "创建人")
private String createBy;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description="创建时间")
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
@Schema(description = "创建时间")
private LocalDateTime createTime;
/**
* 修改人
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="修改人")
/**
* 修改人
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description = "修改人")
private String updateBy;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description="修改时间")
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@Schema(description = "修改时间")
private LocalDateTime updateTime;
/**
* 删除标记
*/
/**
* 删除标记
*/
@TableLogic
@TableField(fill = FieldFill.INSERT)
@Schema(description="删除标记")
@TableField(fill = FieldFill.INSERT)
@Schema(description = "删除标记")
private String delFlag;
/**
* 租户ID
*/
@Schema(description="租户ID")
/**
* 租户ID
*/
@Schema(description = "租户ID")
private Long tenantId;
}
@@ -7,8 +7,12 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.dzc.entity.HardDoorFlowEntity;
import com.bsd.pjcloud.dzc.service.HardDoorFlowService;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
import com.bsd.pjcloud.common.security.util.SecurityUtils;
import com.bsd.pjcloud.hard.api.constant.HardDoorFlowEnum;
import com.bsd.pjcloud.hard.api.dto.HardDoorFlowOpenDto;
import com.bsd.pjcloud.hard.api.entity.HardDoorFlowEntity;
import com.bsd.pjcloud.hard.service.HardDoorFlowService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
@@ -17,6 +21,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;
@@ -27,56 +32,71 @@ import java.util.Objects;
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/hard-door-flow" )
@Tag(description = "hard-door-flow" , name = "智能柜流程管理" )
@RequestMapping("/hard-door-flow")
@Tag(description = "hard-door-flow", name = "智能柜流程管理")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class HardDoorFlowController {
private final HardDoorFlowService hardDoorFlowService;
private final HardDoorFlowService hardDoorFlowService;
@Operation(summary = "分页查询" , description = "分页查询" )
@GetMapping("/page" )
@PreAuthorize("@pms.hasPermission('dzc_hardDoorFlow_view')" )
/* ************************************* start app start ************************************* */
/* ************************************* end app end ************************************* */
@Operation(summary = "检修开门", description = "检修开门")
@PostMapping("/open-access")
public R openAccess(@Validated @RequestBody HardDoorFlowOpenDto dto) {
PjcloudUser user = SecurityUtils.getUser();
dto.setType(HardDoorFlowEnum.ACCESS_OPEN);
dto.setUserId(user.getId());
hardDoorFlowService.openDoorAccess(dto);
return R.ok();
}
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('dzc_hardDoorFlow_view')")
public R getHardDoorFlowPage(@ParameterObject Page page, @ParameterObject HardDoorFlowEntity hardDoorFlow) {
LambdaQueryWrapper<HardDoorFlowEntity> wrapper = Wrappers.lambdaQuery();
return R.ok(hardDoorFlowService.page(page, wrapper));
}
@Operation(summary = "通过id查询" , description = "通过id查询" )
@GetMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('dzc_hardDoorFlow_view')" )
public R getById(@PathVariable("id" ) Long id) {
@Operation(summary = "通过id查询", description = "通过id查询")
@GetMapping("/{id}")
@PreAuthorize("@pms.hasPermission('dzc_hardDoorFlow_view')")
public R getById(@PathVariable("id") Long id) {
return R.ok(hardDoorFlowService.getById(id));
}
@Operation(summary = "新增智能柜流程" , description = "新增智能柜流程" )
@SysLog("新增智能柜流程" )
@Operation(summary = "新增智能柜流程", description = "新增智能柜流程")
@SysLog("新增智能柜流程")
@PostMapping
@PreAuthorize("@pms.hasPermission('dzc_hardDoorFlow_add')" )
@PreAuthorize("@pms.hasPermission('dzc_hardDoorFlow_add')")
public R save(@RequestBody HardDoorFlowEntity hardDoorFlow) {
return R.ok(hardDoorFlowService.save(hardDoorFlow));
}
@Operation(summary = "修改智能柜流程" , description = "修改智能柜流程" )
@SysLog("修改智能柜流程" )
@Operation(summary = "修改智能柜流程", description = "修改智能柜流程")
@SysLog("修改智能柜流程")
@PutMapping
@PreAuthorize("@pms.hasPermission('dzc_hardDoorFlow_edit')" )
@PreAuthorize("@pms.hasPermission('dzc_hardDoorFlow_edit')")
public R updateById(@RequestBody HardDoorFlowEntity hardDoorFlow) {
return R.ok(hardDoorFlowService.updateById(hardDoorFlow));
}
@Operation(summary = "通过id删除智能柜流程" , description = "通过id删除智能柜流程" )
@SysLog("通过id删除智能柜流程" )
@Operation(summary = "通过id删除智能柜流程", description = "通过id删除智能柜流程")
@SysLog("通过id删除智能柜流程")
@DeleteMapping
@PreAuthorize("@pms.hasPermission('dzc_hardDoorFlow_del')" )
@PreAuthorize("@pms.hasPermission('dzc_hardDoorFlow_del')")
public R removeById(@RequestBody Long[] ids) {
return R.ok(hardDoorFlowService.removeBatchByIds(CollUtil.toList(ids)));
}
@ResponseExcel
@GetMapping("/export")
@PreAuthorize("@pms.hasPermission('dzc_hardDoorFlow_export')" )
public List<HardDoorFlowEntity> export(HardDoorFlowEntity hardDoorFlow,Long[] ids) {
@PreAuthorize("@pms.hasPermission('dzc_hardDoorFlow_export')")
public List<HardDoorFlowEntity> export(HardDoorFlowEntity hardDoorFlow, Long[] ids) {
return hardDoorFlowService.list(Wrappers.lambdaQuery(hardDoorFlow).in(ArrayUtil.isNotEmpty(ids), HardDoorFlowEntity::getId, ids));
}
}
@@ -60,6 +60,14 @@ public class HardSpuController {
return R.ok();
}
@Operation(summary = "下架", description = "下架")
@PostMapping("/un-putaway")
public R unPutaway(@RequestBody HardPutawayDto dto) {
hardSpuService.unPutaway(dto);
return R.ok();
}
@Operation(summary = "下拉查询", description = "下拉查询")
@GetMapping("/select")
public R select(@ParameterObject Page page, @ParameterObject HardSpuDto dto) {
@@ -1,8 +1,30 @@
package com.bsd.pjcloud.hard.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.hard.api.dto.HardDoorFlowOpenDto;
import com.bsd.pjcloud.hard.api.entity.HardDoorFlowEntity;
import com.bsd.pjcloud.hard.api.vo.manager.HardDoorManagerVo;
public interface HardDoorFlowService extends IService<HardDoorFlowEntity> {
/**
* 开门
*/
void openDoor(HardDoorFlowOpenDto dto, HardDoorManagerVo hardDoorVo);
/**
* 检修开门
*/
void openDoorAccess(HardDoorFlowOpenDto dto);
/**
* 购买开门
*/
void openDoorPay(HardDoorFlowOpenDto dto);
/**
* 上架开门
*/
void openDoorRepertory(HardDoorFlowOpenDto dto);
}
@@ -45,6 +45,11 @@ public interface HardSpuService extends IService<HardSpuEntity> {
*/
void putaway(HardPutawayDto dto);
/**
* 下架
*/
void unPutaway(HardPutawayDto dto);
/**
* 拉取旷世商品
*/
@@ -1,14 +1,104 @@
package com.bsd.pjcloud.hard.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.extra.spring.SpringUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.hard.api.dto.HardDoorFlowOpenDto;
import com.bsd.pjcloud.hard.api.entity.HardDoorFlowEntity;
import com.bsd.pjcloud.hard.api.vo.manager.HardDoorManagerVo;
import com.bsd.pjcloud.hard.mapper.HardDoorFlowMapper;
import com.bsd.pjcloud.hard.service.HardDoorFlowService;
import com.bsd.pjcloud.hard.service.HardDoorManagerService;
import com.bsd.pjcloud.thirdparty.api.feign.RemoterThirdDoorApiService;
import com.bsd.pjcloud.thirdparty.dto.door.DoorOpenDto;
import com.bsd.pjcloud.thirdparty.vo.door.DoorOpenVo;
import com.bsd.pjcloud.thirdparty.vo.door.DoorStatusVo;
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;
import java.util.List;
/**
* 智能柜流程
*/
@Validated
@Slf4j
@RequiredArgsConstructor
@Service
public class HardDoorFlowServiceImpl extends ServiceImpl<HardDoorFlowMapper, HardDoorFlowEntity> implements HardDoorFlowService {
private final HardDoorManagerService hardDoorManagerService;
private final RemoterThirdDoorApiService thirdDoorApiService;
/**
* 开门
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void openDoor(HardDoorFlowOpenDto dto, HardDoorManagerVo hardDoorVo) {
HardDoorFlowEntity saveObj = HardDoorFlowEntity.builder().userId(dto.getUserId()).bizType(dto.getType().getType()).build();
baseMapper.insert(saveObj);
// 请求开门
DoorOpenDto openDto = BeanUtil.toBean(dto, DoorOpenDto.class);
openDto.setOutOpenNo(hardDoorVo.getDeviceCode());
openDto.setOutOpenNo(dto.getCabinetNo());
openDto.setDeviceCode(String.valueOf(saveObj.getId()));
DoorOpenVo openVo = thirdDoorApiService.open(openDto).getData();
if (ObjectUtil.isEmpty(openVo) || !openVo.isSuccess()) throw new RuntimeException("开门失败");
HardDoorFlowEntity updateObj = HardDoorFlowEntity.builder().id(saveObj.getId()).openEventId(openVo.getEventId()).openOutOpenNo(openVo.getOutOpenNo()).requestOpenTime(LocalDateTime.now()).build();
baseMapper.updateById(updateObj);
}
/**
* 检修开门
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void openDoorAccess(HardDoorFlowOpenDto dto) {
// 查询智能柜
HardDoorManagerVo doorDetail = checkDeviceAndCabinet(dto.getHardDoorId(), dto.getCabinetNo());
getSelf().openDoor(dto, doorDetail);
}
/**
* 购买开门
*/
@Override
public void openDoorPay(HardDoorFlowOpenDto dto) {
}
/**
* 上架开门
*/
@Override
public void openDoorRepertory(HardDoorFlowOpenDto dto) {
}
/**
* 校验设备和货柜编号
*/
private HardDoorManagerVo checkDeviceAndCabinet(Long hardDoorId, String cabinetNo) {
// 查询智能柜
HardDoorManagerVo doorDetail = hardDoorManagerService.getByHardId(hardDoorId);
if (ObjectUtil.isEmpty(doorDetail)) throw new RuntimeException("智能柜不存在");
List<DoorStatusVo.Cabinet> cabinetList = JSONUtil.toList(doorDetail.getCabinetList(), DoorStatusVo.Cabinet.class);
if (ObjectUtil.isEmpty(cabinetList)) throw new RuntimeException("货柜不存在");
if (ObjectUtil.isEmpty(cabinetList.stream().filter(i -> ObjectUtil.equals(i.getCabinetNo(), cabinetNo)).findFirst().orElse(null))) {
throw new RuntimeException("货柜不存在");
}
return doorDetail;
}
private HardDoorFlowServiceImpl getSelf() {
return SpringUtil.getBean(getClass());
}
}
@@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bsd.pjcloud.common.core.constant.enums.YesNoEnum;
@@ -147,7 +148,32 @@ public class HardSpuServiceImpl extends ServiceImpl<HardSpuMapper, HardSpuEntity
*/
@Override
public void putaway(HardPutawayDto dto) {
// 查询有没有货柜
HardSpuJoinEntity spuJoinDetail = hardSpuJoinService.getOne(new LambdaQueryWrapper<HardSpuJoinEntity>()
.eq(HardSpuJoinEntity::getId, dto.getId())
);
if (ObjectUtil.isEmpty(spuJoinDetail)) throw new RuntimeException("货柜不存在");
LambdaUpdateWrapper<HardSpuJoinEntity> updateObj = new LambdaUpdateWrapper<HardSpuJoinEntity>()
.set(HardSpuJoinEntity::getSpuId, dto.getHardSpuId())
.eq(HardSpuJoinEntity::getId, dto.getId());
hardSpuJoinService.update(updateObj);
}
/**
* 下架
*/
@Override
public void unPutaway(HardPutawayDto dto) {
// 查询有没有商品
HardSpuJoinEntity hardSpuJoinDetail = hardSpuJoinService.getOne(new LambdaQueryWrapper<HardSpuJoinEntity>()
.eq(HardSpuJoinEntity::getSpuId, dto.getHardSpuId())
.eq(HardSpuJoinEntity::getId, dto.getId())
);
if (ObjectUtil.isEmpty(hardSpuJoinDetail)) throw new RuntimeException("该商品不存在");
LambdaUpdateWrapper<HardSpuJoinEntity> updateObj = new LambdaUpdateWrapper<HardSpuJoinEntity>()
.set(HardSpuJoinEntity::getSpuId, null)
.eq(HardSpuJoinEntity::getId, dto.getId());
hardSpuJoinService.update(updateObj);
}
/**