eight
2024-09-06 b84a6ede57a0cf902a43a65d86e5b793997250b8
装机拆机功能
已添加9个文件
已修改2个文件
503 ■■■■■ 文件已修改
jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/ErrorCodeConstants.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/devrent/DevRentController.java 95 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/devrent/vo/DevRentPageReqVO.java 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/devrent/vo/DevRentRespVO.java 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/devrent/vo/DevRentSaveReqVO.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/devrent/DevRentDO.java 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/devrent/DevRentMapper.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devrent/DevRentService.java 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devrent/DevRentServiceImpl.java 75 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jh-module-ecg/jh-module-ecg-biz/src/main/resources/mapper/devrent/DevRentMapper.xml 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
sql/mysql/jh.sql 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/enums/ErrorCodeConstants.java
@@ -25,4 +25,5 @@
    ErrorCode DEV_MODEL_NOT_EXISTS = new ErrorCode(1_010_005_000, "设备型号不存在");
    ErrorCode DEVICE_NOT_EXISTS = new ErrorCode(1_010_005_001,  "设备不存在");
    ErrorCode DEV_RENT_NOT_EXISTS = new ErrorCode(1_010_005_002, "租借不存在");
}
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/devrent/DevRentController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,95 @@
package cn.lihu.jh.module.ecg.controller.admin.devrent;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import java.util.*;
import java.io.IOException;
import cn.lihu.jh.framework.common.pojo.PageParam;
import cn.lihu.jh.framework.common.pojo.PageResult;
import cn.lihu.jh.framework.common.pojo.CommonResult;
import cn.lihu.jh.framework.common.util.object.BeanUtils;
import static cn.lihu.jh.framework.common.pojo.CommonResult.success;
import cn.lihu.jh.framework.excel.core.util.ExcelUtils;
import cn.lihu.jh.framework.apilog.core.annotation.ApiAccessLog;
import static cn.lihu.jh.framework.apilog.core.enums.OperateTypeEnum.*;
import cn.lihu.jh.module.ecg.controller.admin.devrent.vo.*;
import cn.lihu.jh.module.ecg.dal.dataobject.devrent.DevRentDO;
import cn.lihu.jh.module.ecg.service.devrent.DevRentService;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
@Tag(name = "管理后台 - è£…机拆机")
@RestController
@RequestMapping("/ecg/dev-rent")
@Validated
public class DevRentController {
    @Resource
    private DevRentService devRentService;
    @PostMapping("/create")
    @Operation(summary = "创建装机拆机")
    @PreAuthorize("@ss.hasPermission('ecg:dev-rent:create')")
    public CommonResult<Integer> createDevRent(@Valid @RequestBody DevRentSaveReqVO createReqVO) {
        return success(devRentService.createDevRent(createReqVO));
    }
    @PutMapping("/update")
    @Operation(summary = "更新装机拆机")
    @PreAuthorize("@ss.hasPermission('ecg:dev-rent:update')")
    public CommonResult<Boolean> updateDevRent(@Valid @RequestBody DevRentSaveReqVO updateReqVO) {
        devRentService.updateDevRent(updateReqVO);
        return success(true);
    }
    @DeleteMapping("/delete")
    @Operation(summary = "删除装机拆机")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('ecg:dev-rent:delete')")
    public CommonResult<Boolean> deleteDevRent(@RequestParam("id") Integer id) {
        devRentService.deleteDevRent(id);
        return success(true);
    }
    @GetMapping("/get")
    @Operation(summary = "获得装机拆机")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('ecg:dev-rent:query')")
    public CommonResult<DevRentRespVO> getDevRent(@RequestParam("id") Integer id) {
        DevRentDO devRent = devRentService.getDevRent(id);
        return success(BeanUtils.toBean(devRent, DevRentRespVO.class));
    }
    @GetMapping("/page")
    @Operation(summary = "获得装机拆机分页")
    @PreAuthorize("@ss.hasPermission('ecg:dev-rent:query')")
    public CommonResult<PageResult<DevRentRespVO>> getDevRentPage(@Valid DevRentPageReqVO pageReqVO) {
        PageResult<DevRentDO> pageResult = devRentService.getDevRentPage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, DevRentRespVO.class));
    }
    @GetMapping("/export-excel")
    @Operation(summary = "导出装机拆机 Excel")
    @PreAuthorize("@ss.hasPermission('ecg:dev-rent:export')")
    @ApiAccessLog(operateType = EXPORT)
    public void exportDevRentExcel(@Valid DevRentPageReqVO pageReqVO,
              HttpServletResponse response) throws IOException {
        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
        List<DevRentDO> list = devRentService.getDevRentPage(pageReqVO).getList();
        // å¯¼å‡º Excel
        ExcelUtils.write(response, "装机拆机.xls", "数据", DevRentRespVO.class,
                        BeanUtils.toBean(list, DevRentRespVO.class));
    }
}
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/devrent/vo/DevRentPageReqVO.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,51 @@
package cn.lihu.jh.module.ecg.controller.admin.devrent.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.lihu.jh.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.lihu.jh.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - è£…机拆机分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class DevRentPageReqVO extends PageParam {
    @Schema(description = "设备编号", example = "3986")
    private String devId;
    @Schema(description = "患者编号", example = "4973")
    private String patId;
    @Schema(description = "患者名称", example = "芋艿")
    private String patName;
    @Schema(description = "装机时间")
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime[] rentTime;
    @Schema(description = "拆机时间")
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime[] returnTime;
    @Schema(description = "干扰数")
    private Integer interference;
    @Schema(description = "基线粗")
    private String baseline;
    @Schema(description = "脱离")
    private String detachment;
    @Schema(description = "备注", example = "你猜")
    private String remark;
    @Schema(description = "创建时间")
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime[] createTime;
}
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/devrent/vo/DevRentRespVO.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,59 @@
package cn.lihu.jh.module.ecg.controller.admin.devrent.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - è£…机拆机 Response VO")
@Data
@ExcelIgnoreUnannotated
public class DevRentRespVO {
    @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "26525")
    @ExcelProperty("id")
    private Integer id;
    @Schema(description = "设备编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3986")
    @ExcelProperty("设备编号")
    private String devId;
    @Schema(description = "患者编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4973")
    @ExcelProperty("患者编号")
    private String patId;
    @Schema(description = "患者名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
    @ExcelProperty("患者名称")
    private String patName;
    @Schema(description = "装机时间")
    @ExcelProperty("装机时间")
    private LocalDateTime rentTime;
    @Schema(description = "拆机时间")
    @ExcelProperty("拆机时间")
    private LocalDateTime returnTime;
    @Schema(description = "干扰数")
    @ExcelProperty("干扰数")
    private Integer interference;
    @Schema(description = "基线粗")
    @ExcelProperty("基线粗")
    private String baseline;
    @Schema(description = "脱离")
    @ExcelProperty("脱离")
    private String detachment;
    @Schema(description = "备注", example = "你猜")
    @ExcelProperty("备注")
    private String remark;
    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @ExcelProperty("创建时间")
    private LocalDateTime createTime;
}
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/devrent/vo/DevRentSaveReqVO.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,46 @@
package cn.lihu.jh.module.ecg.controller.admin.devrent.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import javax.validation.constraints.NotEmpty;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - è£…机拆机新增/修改 Request VO")
@Data
public class DevRentSaveReqVO {
    @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "26525")
    private Integer id;
    @Schema(description = "设备编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3986")
    @NotEmpty(message = "设备编号不能为空")
    private String devId;
    @Schema(description = "患者编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4973")
    @NotEmpty(message = "患者编号不能为空")
    private String patId;
    @Schema(description = "患者名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
    @NotEmpty(message = "患者名称不能为空")
    private String patName;
    @Schema(description = "装机时间")
    private LocalDateTime rentTime;
    @Schema(description = "拆机时间")
    private LocalDateTime returnTime;
    @Schema(description = "干扰数")
    private Integer interference;
    @Schema(description = "基线粗")
    private String baseline;
    @Schema(description = "脱离")
    private String detachment;
    @Schema(description = "备注", example = "你猜")
    private String remark;
}
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/dataobject/devrent/DevRentDO.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,69 @@
package cn.lihu.jh.module.ecg.dal.dataobject.devrent;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.lihu.jh.framework.mybatis.core.dataobject.BaseDO;
/**
 * è£…机拆机 DO
 *
 * @author èŠ‹é“æºç 
 */
@TableName("dev_rent")
@KeySequence("dev_rent_seq") // ç”¨äºŽ Oracle、PostgreSQL、Kingbase、DB2、H2 æ•°æ®åº“的主键自增。如果是 MySQL ç­‰æ•°æ®åº“,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class DevRentDO extends BaseDO {
    /**
     * id
     */
    @TableId
    private Integer id;
    /**
     * è®¾å¤‡ç¼–号
     */
    private String devId;
    /**
     * æ‚£è€…编号
     */
    private String patId;
    /**
     * æ‚£è€…名称
     */
    private String patName;
    /**
     * è£…机时间
     */
    private LocalDateTime rentTime;
    /**
     * æ‹†æœºæ—¶é—´
     */
    private LocalDateTime returnTime;
    /**
     * å¹²æ‰°æ•°
     */
    private Integer interference;
    /**
     * åŸºçº¿ç²—
     */
    private String baseline;
    /**
     * è„±ç¦»
     */
    private String detachment;
    /**
     * å¤‡æ³¨
     */
    private String remark;
}
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/devrent/DevRentMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,35 @@
package cn.lihu.jh.module.ecg.dal.mysql.devrent;
import java.util.*;
import cn.lihu.jh.framework.common.pojo.PageResult;
import cn.lihu.jh.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.lihu.jh.framework.mybatis.core.mapper.BaseMapperX;
import cn.lihu.jh.module.ecg.dal.dataobject.devrent.DevRentDO;
import org.apache.ibatis.annotations.Mapper;
import cn.lihu.jh.module.ecg.controller.admin.devrent.vo.*;
/**
 * è£…机拆机 Mapper
 *
 * @author èŠ‹é“æºç 
 */
@Mapper
public interface DevRentMapper extends BaseMapperX<DevRentDO> {
    default PageResult<DevRentDO> selectPage(DevRentPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DevRentDO>()
                .eqIfPresent(DevRentDO::getDevId, reqVO.getDevId())
                .eqIfPresent(DevRentDO::getPatId, reqVO.getPatId())
                .likeIfPresent(DevRentDO::getPatName, reqVO.getPatName())
                .betweenIfPresent(DevRentDO::getRentTime, reqVO.getRentTime())
                .betweenIfPresent(DevRentDO::getReturnTime, reqVO.getReturnTime())
                .eqIfPresent(DevRentDO::getInterference, reqVO.getInterference())
                .eqIfPresent(DevRentDO::getBaseline, reqVO.getBaseline())
                .eqIfPresent(DevRentDO::getDetachment, reqVO.getDetachment())
                .eqIfPresent(DevRentDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(DevRentDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DevRentDO::getId));
    }
}
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devrent/DevRentService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,56 @@
package cn.lihu.jh.module.ecg.service.devrent;
import java.util.*;
import cn.lihu.jh.module.ecg.controller.admin.devrent.vo.*;
import cn.lihu.jh.module.ecg.dal.dataobject.devrent.DevRentDO;
import cn.lihu.jh.framework.common.pojo.PageResult;
import cn.lihu.jh.framework.common.pojo.PageParam;
import javax.validation.Valid;
/**
 * è£…机拆机 Service æŽ¥å£
 *
 * @author èŠ‹é“æºç 
 */
public interface DevRentService {
    /**
     * åˆ›å»ºè£…机拆机
     *
     * @param createReqVO åˆ›å»ºä¿¡æ¯
     * @return ç¼–号
     */
    Integer createDevRent(@Valid DevRentSaveReqVO createReqVO);
    /**
     * æ›´æ–°è£…机拆机
     *
     * @param updateReqVO æ›´æ–°ä¿¡æ¯
     */
    void updateDevRent(@Valid DevRentSaveReqVO updateReqVO);
    /**
     * åˆ é™¤è£…机拆机
     *
     * @param id ç¼–号
     */
    void deleteDevRent(Integer id);
    /**
     * èŽ·å¾—è£…æœºæ‹†æœº
     *
     * @param id ç¼–号
     * @return è£…机拆机
     */
    DevRentDO getDevRent(Integer id);
    /**
     * èŽ·å¾—è£…æœºæ‹†æœºåˆ†é¡µ
     *
     * @param pageReqVO åˆ†é¡µæŸ¥è¯¢
     * @return è£…机拆机分页
     */
    PageResult<DevRentDO> getDevRentPage(DevRentPageReqVO pageReqVO);
}
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/devrent/DevRentServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,75 @@
package cn.lihu.jh.module.ecg.service.devrent;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import cn.lihu.jh.module.ecg.controller.admin.devrent.vo.*;
import cn.lihu.jh.module.ecg.dal.dataobject.devrent.DevRentDO;
import cn.lihu.jh.framework.common.pojo.PageResult;
import cn.lihu.jh.framework.common.pojo.PageParam;
import cn.lihu.jh.framework.common.util.object.BeanUtils;
import cn.lihu.jh.module.ecg.dal.mysql.devrent.DevRentMapper;
import javax.annotation.Resource;
import static cn.lihu.jh.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.lihu.jh.module.ecg.enums.ErrorCodeConstants.*;
/**
 * è£…机拆机 Service å®žçŽ°ç±»
 *
 * @author èŠ‹é“æºç 
 */
@Service
@Validated
public class DevRentServiceImpl implements DevRentService {
    @Resource
    private DevRentMapper devRentMapper;
    @Override
    public Integer createDevRent(DevRentSaveReqVO createReqVO) {
        // æ’å…¥
        DevRentDO devRent = BeanUtils.toBean(createReqVO, DevRentDO.class);
        devRentMapper.insert(devRent);
        // è¿”回
        return devRent.getId();
    }
    @Override
    public void updateDevRent(DevRentSaveReqVO updateReqVO) {
        // æ ¡éªŒå­˜åœ¨
        validateDevRentExists(updateReqVO.getId());
        // æ›´æ–°
        DevRentDO updateObj = BeanUtils.toBean(updateReqVO, DevRentDO.class);
        devRentMapper.updateById(updateObj);
    }
    @Override
    public void deleteDevRent(Integer id) {
        // æ ¡éªŒå­˜åœ¨
        validateDevRentExists(id);
        // åˆ é™¤
        devRentMapper.deleteById(id);
    }
    private void validateDevRentExists(Integer id) {
        if (devRentMapper.selectById(id) == null) {
            throw exception(DEV_RENT_NOT_EXISTS);
        }
    }
    @Override
    public DevRentDO getDevRent(Integer id) {
        return devRentMapper.selectById(id);
    }
    @Override
    public PageResult<DevRentDO> getDevRentPage(DevRentPageReqVO pageReqVO) {
        return devRentMapper.selectPage(pageReqVO);
    }
}
jh-module-ecg/jh-module-ecg-biz/src/main/resources/mapper/devrent/DevRentMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,12 @@
<?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="cn.lihu.jh.module.ecg.dal.mysql.devrent.DevRentMapper">
    <!--
        ä¸€èˆ¬æƒ…况下,尽可能使用 Mapper è¿›è¡Œ CRUD å¢žåˆ æ”¹æŸ¥å³å¯ã€‚
        æ— æ³•满足的场景,例如说多表关联查询,才使用 XML ç¼–写 SQL。
        ä»£ç ç”Ÿæˆå™¨æš‚时只生成 Mapper XML æ–‡ä»¶æœ¬èº«ï¼Œæ›´å¤šæŽ¨è MybatisX å¿«é€Ÿå¼€å‘插件来生成查询。
        æ–‡æ¡£å¯è§ï¼šhttps://www.iocoder.cn/MyBatis/x-plugins/
     -->
</mapper>
sql/mysql/jh.sql
@@ -151,9 +151,11 @@
  `detachment` varchar(100) DEFAULT NULL COMMENT '脱离',  
  `remark` varchar(100) DEFAULT NULL COMMENT '备注',
  `tenant_id` int DEFAULT 1 COMMENT '租户编号',
  `creator` varchar(10) DEFAULT '' COMMENT '创建者',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  `updater` varchar(10) DEFAULT '' COMMENT '更新者',
  `update_time` datetime NOT NULL COMMENT '更新时间',
  `deleted` bit(1) DEFAULT 0,
  `deleted` bit(1) DEFAULT 0 COMMENT '删除标记',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='装机拆机表';