检查项目设置-套餐设置
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package com.openhis.web.check.appservice;
|
||||
|
||||
import com.core.common.core.domain.R;
|
||||
import com.openhis.web.check.dto.CheckPackageDto;
|
||||
|
||||
/**
|
||||
* 检查套餐AppService接口
|
||||
*
|
||||
* @author system
|
||||
* @date 2025-11-26
|
||||
*/
|
||||
public interface ICheckPackageAppService {
|
||||
|
||||
/**
|
||||
* 获取检查套餐列表
|
||||
* @return 检查套餐列表
|
||||
*/
|
||||
R<?> getCheckPackageList();
|
||||
|
||||
/**
|
||||
* 根据ID获取检查套餐详情
|
||||
* @param id 套餐ID
|
||||
* @return 套餐详情
|
||||
*/
|
||||
R<?> getCheckPackageById(Long id);
|
||||
|
||||
/**
|
||||
* 新增检查套餐
|
||||
* @param checkPackageDto 套餐信息
|
||||
* @return 新增结果
|
||||
*/
|
||||
R<?> addCheckPackage(CheckPackageDto checkPackageDto);
|
||||
|
||||
/**
|
||||
* 更新检查套餐
|
||||
* @param checkPackageDto 套餐信息
|
||||
* @return 更新结果
|
||||
*/
|
||||
R<?> updateCheckPackage(CheckPackageDto checkPackageDto);
|
||||
|
||||
/**
|
||||
* 删除检查套餐
|
||||
* @param id 套餐ID
|
||||
* @return 删除结果
|
||||
*/
|
||||
R<?> deleteCheckPackage(Long id);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
package com.openhis.web.check.appservice.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.core.common.core.domain.R;
|
||||
import com.openhis.check.domain.CheckPackage;
|
||||
import com.openhis.check.domain.CheckPackageDetail;
|
||||
import com.openhis.check.service.ICheckPackageDetailService;
|
||||
import com.openhis.check.service.ICheckPackageService;
|
||||
import com.openhis.web.check.appservice.ICheckPackageAppService;
|
||||
import com.openhis.web.check.dto.CheckPackageDetailDto;
|
||||
import com.openhis.web.check.dto.CheckPackageDto;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 检查套餐AppService实现
|
||||
*
|
||||
* @author system
|
||||
* @date 2025-11-26
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class CheckPackageAppServiceImpl implements ICheckPackageAppService {
|
||||
|
||||
private final ICheckPackageService checkPackageService;
|
||||
private final ICheckPackageDetailService checkPackageDetailService;
|
||||
|
||||
@Override
|
||||
public R<?> getCheckPackageList() {
|
||||
try {
|
||||
List<CheckPackage> list = checkPackageService.list();
|
||||
return R.ok(list);
|
||||
} catch (Exception e) {
|
||||
log.error("获取检查套餐列表失败", e);
|
||||
return R.fail("获取检查套餐列表失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> getCheckPackageById(Long id) {
|
||||
try {
|
||||
CheckPackage checkPackage = checkPackageService.getById(id);
|
||||
if (checkPackage == null) {
|
||||
return R.fail("套餐不存在");
|
||||
}
|
||||
|
||||
// 获取套餐明细
|
||||
List<CheckPackageDetail> details = checkPackageDetailService.list(
|
||||
new LambdaQueryWrapper<CheckPackageDetail>()
|
||||
.eq(CheckPackageDetail::getPackageId, id)
|
||||
.orderByAsc(CheckPackageDetail::getOrderNum)
|
||||
);
|
||||
|
||||
// 转换为DTO
|
||||
CheckPackageDto dto = new CheckPackageDto();
|
||||
BeanUtils.copyProperties(checkPackage, dto);
|
||||
|
||||
List<CheckPackageDetailDto> detailDtos = details.stream().map(detail -> {
|
||||
CheckPackageDetailDto detailDto = new CheckPackageDetailDto();
|
||||
BeanUtils.copyProperties(detail, detailDto);
|
||||
return detailDto;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
dto.setItems(detailDtos);
|
||||
|
||||
return R.ok(dto);
|
||||
} catch (Exception e) {
|
||||
log.error("获取检查套餐详情失败", e);
|
||||
return R.fail("获取检查套餐详情失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<?> addCheckPackage(CheckPackageDto checkPackageDto) {
|
||||
try {
|
||||
// 创建套餐主表数据
|
||||
CheckPackage checkPackage = new CheckPackage();
|
||||
BeanUtils.copyProperties(checkPackageDto, checkPackage);
|
||||
|
||||
// 设置套餐维护日期为当前系统日期
|
||||
checkPackage.setMaintainDate(LocalDate.now());
|
||||
checkPackage.setCreateTime(LocalDateTime.now());
|
||||
checkPackage.setUpdateTime(LocalDateTime.now());
|
||||
|
||||
// 保存套餐主表
|
||||
boolean saveResult = checkPackageService.save(checkPackage);
|
||||
if (!saveResult) {
|
||||
return R.fail("保存套餐失败");
|
||||
}
|
||||
|
||||
// 保存套餐明细
|
||||
if (checkPackageDto.getItems() != null && !checkPackageDto.getItems().isEmpty()) {
|
||||
List<CheckPackageDetail> details = new ArrayList<>();
|
||||
int orderNum = 1;
|
||||
for (CheckPackageDetailDto detailDto : checkPackageDto.getItems()) {
|
||||
CheckPackageDetail detail = new CheckPackageDetail();
|
||||
BeanUtils.copyProperties(detailDto, detail);
|
||||
detail.setPackageId(checkPackage.getId());
|
||||
detail.setOrderNum(orderNum++);
|
||||
detail.setCreateTime(LocalDateTime.now());
|
||||
detail.setUpdateTime(LocalDateTime.now());
|
||||
details.add(detail);
|
||||
}
|
||||
checkPackageDetailService.saveBatch(details);
|
||||
}
|
||||
|
||||
return R.ok(checkPackage.getId(), "保存成功");
|
||||
} catch (Exception e) {
|
||||
log.error("新增检查套餐失败", e);
|
||||
return R.fail("新增检查套餐失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<?> updateCheckPackage(CheckPackageDto checkPackageDto) {
|
||||
try {
|
||||
// 检查套餐是否存在
|
||||
CheckPackage existPackage = checkPackageService.getById(checkPackageDto.getId());
|
||||
if (existPackage == null) {
|
||||
return R.fail("套餐不存在");
|
||||
}
|
||||
|
||||
// 更新套餐主表数据
|
||||
CheckPackage checkPackage = new CheckPackage();
|
||||
BeanUtils.copyProperties(checkPackageDto, checkPackage);
|
||||
|
||||
// 更新套餐维护日期为当前系统日期
|
||||
checkPackage.setMaintainDate(LocalDate.now());
|
||||
checkPackage.setUpdateTime(LocalDateTime.now());
|
||||
|
||||
boolean updateResult = checkPackageService.updateById(checkPackage);
|
||||
if (!updateResult) {
|
||||
return R.fail("更新套餐失败");
|
||||
}
|
||||
|
||||
// 删除原有明细
|
||||
checkPackageDetailService.remove(
|
||||
new LambdaQueryWrapper<CheckPackageDetail>()
|
||||
.eq(CheckPackageDetail::getPackageId, checkPackage.getId())
|
||||
);
|
||||
|
||||
// 保存新的套餐明细
|
||||
if (checkPackageDto.getItems() != null && !checkPackageDto.getItems().isEmpty()) {
|
||||
List<CheckPackageDetail> details = new ArrayList<>();
|
||||
int orderNum = 1;
|
||||
for (CheckPackageDetailDto detailDto : checkPackageDto.getItems()) {
|
||||
CheckPackageDetail detail = new CheckPackageDetail();
|
||||
BeanUtils.copyProperties(detailDto, detail);
|
||||
detail.setPackageId(checkPackage.getId());
|
||||
detail.setOrderNum(orderNum++);
|
||||
detail.setCreateTime(LocalDateTime.now());
|
||||
detail.setUpdateTime(LocalDateTime.now());
|
||||
details.add(detail);
|
||||
}
|
||||
checkPackageDetailService.saveBatch(details);
|
||||
}
|
||||
|
||||
return R.ok("更新成功");
|
||||
} catch (Exception e) {
|
||||
log.error("更新检查套餐失败", e);
|
||||
return R.fail("更新检查套餐失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public R<?> deleteCheckPackage(Long id) {
|
||||
try {
|
||||
// 检查套餐是否存在
|
||||
CheckPackage existPackage = checkPackageService.getById(id);
|
||||
if (existPackage == null) {
|
||||
return R.fail("套餐不存在");
|
||||
}
|
||||
|
||||
// 删除套餐明细
|
||||
checkPackageDetailService.remove(
|
||||
new LambdaQueryWrapper<CheckPackageDetail>()
|
||||
.eq(CheckPackageDetail::getPackageId, id)
|
||||
);
|
||||
|
||||
// 删除套餐主表
|
||||
boolean deleteResult = checkPackageService.removeById(id);
|
||||
if (!deleteResult) {
|
||||
return R.fail("删除套餐失败");
|
||||
}
|
||||
|
||||
return R.ok("删除成功");
|
||||
} catch (Exception e) {
|
||||
log.error("删除检查套餐失败", e);
|
||||
return R.fail("删除检查套餐失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.openhis.web.check.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.core.common.core.controller.BaseController;
|
||||
import com.core.common.core.domain.AjaxResult;
|
||||
import com.core.common.core.domain.R;
|
||||
import com.openhis.check.domain.CheckMethod;
|
||||
import com.openhis.check.domain.CheckPackage;
|
||||
import com.openhis.check.domain.CheckPart;
|
||||
@@ -9,12 +12,13 @@ import com.openhis.check.service.ICheckMethodService;
|
||||
import com.openhis.check.service.ICheckPackageService;
|
||||
import com.openhis.check.service.ICheckPartService;
|
||||
import com.openhis.check.service.ICheckTypeService;
|
||||
import com.openhis.web.check.appservice.ICheckPackageAppService;
|
||||
import com.openhis.web.check.dto.CheckPackageDto;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.core.common.core.controller.BaseController;
|
||||
import com.core.common.core.domain.AjaxResult;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -22,6 +26,7 @@ import java.util.List;
|
||||
*
|
||||
* @author system
|
||||
* @date 2025-07-22
|
||||
* @updated 2025-11-26 - 增加套餐设置相关接口
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping({"/system/check-type", "/system"})
|
||||
@@ -33,6 +38,7 @@ public class CheckTypeController extends BaseController {
|
||||
private final ICheckMethodService checkMethodService;
|
||||
private final ICheckPartService checkPartService;
|
||||
private final ICheckPackageService checkPackageService;
|
||||
private final ICheckPackageAppService checkPackageAppService;
|
||||
|
||||
/**
|
||||
* 获取检查类型列表
|
||||
@@ -93,4 +99,36 @@ public class CheckTypeController extends BaseController {
|
||||
public AjaxResult remove(@PathVariable Long checkTypeId) {
|
||||
return toAjax(checkTypeService.removeById(checkTypeId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID获取检查套餐详情
|
||||
*/
|
||||
@GetMapping({"/package/{id}", "/check-package/{id}"})
|
||||
public R<?> getCheckPackageById(@PathVariable Long id) {
|
||||
return checkPackageAppService.getCheckPackageById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增检查套餐
|
||||
*/
|
||||
@PostMapping({"/package", "/check-package"})
|
||||
public R<?> addCheckPackage(@Valid @RequestBody CheckPackageDto checkPackageDto) {
|
||||
return checkPackageAppService.addCheckPackage(checkPackageDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新检查套餐
|
||||
*/
|
||||
@PutMapping({"/package", "/check-package"})
|
||||
public R<?> updateCheckPackage(@Valid @RequestBody CheckPackageDto checkPackageDto) {
|
||||
return checkPackageAppService.updateCheckPackage(checkPackageDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除检查套餐
|
||||
*/
|
||||
@DeleteMapping({"/package/{id}", "/check-package/{id}"})
|
||||
public R<?> deleteCheckPackage(@PathVariable Long id) {
|
||||
return checkPackageAppService.deleteCheckPackage(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.openhis.web.check.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 检查套餐明细DTO
|
||||
*
|
||||
* @author system
|
||||
* @date 2025-11-26
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class CheckPackageDetailDto {
|
||||
|
||||
/** 套餐明细ID */
|
||||
private Long id;
|
||||
|
||||
/** 套餐ID */
|
||||
private Long packageId;
|
||||
|
||||
/** 项目编号 */
|
||||
private String itemCode;
|
||||
|
||||
/** 项目名称/规格 */
|
||||
@NotBlank(message = "项目名称不能为空")
|
||||
private String itemName;
|
||||
|
||||
/** 检查项目ID(诊疗项目ID) */
|
||||
private Long checkItemId;
|
||||
|
||||
/** 剂量 */
|
||||
private String dose;
|
||||
|
||||
/** 途径 */
|
||||
private String method;
|
||||
|
||||
/** 频次 */
|
||||
private String frequency;
|
||||
|
||||
/** 天数 */
|
||||
private String days;
|
||||
|
||||
/** 数量 */
|
||||
@NotNull(message = "数量不能为空")
|
||||
private Integer quantity;
|
||||
|
||||
/** 单价 */
|
||||
@NotNull(message = "单价不能为空")
|
||||
private BigDecimal unitPrice;
|
||||
|
||||
/** 金额 */
|
||||
private BigDecimal amount;
|
||||
|
||||
/** 服务费 */
|
||||
private BigDecimal serviceCharge;
|
||||
|
||||
/** 总金额 */
|
||||
private BigDecimal total;
|
||||
|
||||
/** 产地 */
|
||||
private String origin;
|
||||
|
||||
/** 序号 */
|
||||
private Integer orderNum;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.openhis.web.check.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 检查套餐DTO
|
||||
*
|
||||
* @author system
|
||||
* @date 2025-11-26
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class CheckPackageDto {
|
||||
|
||||
/** 检查套餐ID */
|
||||
private Long id;
|
||||
|
||||
/** 套餐名称 */
|
||||
@NotBlank(message = "套餐名称不能为空")
|
||||
private String packageName;
|
||||
|
||||
/** 套餐编码 */
|
||||
private String code;
|
||||
|
||||
/** 套餐类别 */
|
||||
@NotBlank(message = "套餐类别不能为空")
|
||||
private String packageType;
|
||||
|
||||
/** 套餐级别 */
|
||||
@NotBlank(message = "套餐级别不能为空")
|
||||
private String packageLevel;
|
||||
|
||||
/** 适用科室 */
|
||||
private String department;
|
||||
|
||||
/** 适用用户 */
|
||||
private String user;
|
||||
|
||||
/** 卫生机构 */
|
||||
private String organization;
|
||||
|
||||
/** 套餐金额 */
|
||||
private BigDecimal packagePrice;
|
||||
|
||||
/** 折扣 */
|
||||
private BigDecimal discount;
|
||||
|
||||
/** 制单人 */
|
||||
private String creator;
|
||||
|
||||
/** 是否停用 */
|
||||
private Integer isDisabled;
|
||||
|
||||
/** 显示套餐名 */
|
||||
private Integer showPackageName;
|
||||
|
||||
/** 生成服务费 */
|
||||
private Integer generateServiceFee;
|
||||
|
||||
/** 套餐价格启用状态 */
|
||||
private Integer packagePriceEnabled;
|
||||
|
||||
/** 服务费 */
|
||||
private BigDecimal serviceFee;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
/** 描述 */
|
||||
private String description;
|
||||
|
||||
/** 套餐维护日期 */
|
||||
private LocalDate createDate;
|
||||
|
||||
/** 套餐明细列表 */
|
||||
@NotNull(message = "套餐明细不能为空")
|
||||
private List<CheckPackageDetailDto> items;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user