套餐设置套餐管理完善

This commit is contained in:
2026-01-28 14:26:41 +08:00
parent 41494ebf7c
commit 0cecf3bcad
11 changed files with 299 additions and 65 deletions

View File

@@ -2,6 +2,8 @@ package com.openhis.lab.domain;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.experimental.Accessors;
@@ -21,9 +23,28 @@ public class InspectionPackage {
private static final long serialVersionUID = 1L;
/** 套餐ID */
@TableId(type = IdType.ASSIGN_ID)
@TableId(value = "basic_information_id", type = IdType.AUTO)
@JsonProperty("packageId") // 保持向后兼容
private String basicInformationId;
@JsonSerialize(using = ToStringSerializer.class) // 避免前端JS精度丢失
private Long basicInformationId;
/**
* 兼容前端常见主键字段名id
* - 输出id = basicInformationId字符串避免 JS 精度丢失)
* - 输入:允许前端传 id 回来时反序列化到 basicInformationId
*/
@JsonProperty("id")
public String getId() {
return basicInformationId == null ? null : String.valueOf(basicInformationId);
}
@JsonProperty("id")
public void setId(String id) {
if (id == null || id.isBlank()) {
return;
}
this.basicInformationId = Long.valueOf(id);
}
/** 套餐类别,固定值:"检验套餐" */
private String packageCategory;

View File

@@ -2,6 +2,8 @@ package com.openhis.lab.domain;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.experimental.Accessors;
@@ -26,7 +28,8 @@ public class InspectionPackageDetail {
/** 套餐ID */
@JsonProperty("packageId") // 保持向后兼容
private String basicInformationId;
@JsonSerialize(using = ToStringSerializer.class) // 避免前端JS精度丢失
private Long basicInformationId;
/** 套餐名称 */
private String packageName;

View File

@@ -20,14 +20,14 @@ public interface InspectionPackageDetailMapper extends BaseMapper<InspectionPack
* @param packageId 套餐ID
* @return 删除的记录数
*/
int deleteByPackageId(String packageId);
int deleteByPackageId(Long packageId);
/**
* 根据套餐ID查询明细列表
* @param packageId 套餐ID
* @return 明细列表
*/
List<InspectionPackageDetail> selectByPackageId(String packageId);
List<InspectionPackageDetail> selectByPackageId(Long packageId);
/**
* 批量插入明细数据

View File

@@ -18,7 +18,7 @@ public interface IInspectionPackageDetailService extends IService<InspectionPack
* @param packageId 套餐ID
* @return 明细列表
*/
List<InspectionPackageDetail> selectDetailsByPackageId(String packageId);
List<InspectionPackageDetail> selectDetailsByPackageId(Long packageId);
/**
* 批量保存明细数据
@@ -26,7 +26,7 @@ public interface IInspectionPackageDetailService extends IService<InspectionPack
* @param details 明细数据列表
* @return 保存结果 {successCount: 成功数量, failCount: 失败数量}
*/
java.util.Map<String, Integer> batchSaveDetails(String packageId, List<InspectionPackageDetail> details);
java.util.Map<String, Integer> batchSaveDetails(Long packageId, List<InspectionPackageDetail> details);
/**
* 保存单个明细数据
@@ -47,7 +47,7 @@ public interface IInspectionPackageDetailService extends IService<InspectionPack
* @param packageId 套餐ID
* @return 删除数量
*/
int deleteByPackageId(String packageId);
int deleteByPackageId(Long packageId);
/**
* 计算明细数据的总金额和服务费

View File

@@ -20,7 +20,7 @@ public interface IInspectionPackageService extends IService<InspectionPackage> {
* @param excludeId 排除的ID用于更新时
* @return true-唯一false-不唯一
*/
boolean checkPackageNameUnique(String packageName, String orgName, String excludeId);
boolean checkPackageNameUnique(String packageName, String orgName, Long excludeId);
/**
* 根据条件查询套餐列表(分页)
@@ -36,7 +36,7 @@ public interface IInspectionPackageService extends IService<InspectionPackage> {
* @param packageId 套餐ID
* @return 套餐信息
*/
InspectionPackage selectPackageById(String packageId);
InspectionPackage selectPackageById(Long packageId);
/**
* 新增检验套餐
@@ -57,5 +57,5 @@ public interface IInspectionPackageService extends IService<InspectionPackage> {
* @param packageId 套餐ID
* @return 结果
*/
boolean deletePackage(String packageId);
boolean deletePackage(Long packageId);
}

View File

@@ -26,13 +26,13 @@ import java.util.Map;
public class InspectionPackageDetailServiceImpl extends ServiceImpl<InspectionPackageDetailMapper, InspectionPackageDetail> implements IInspectionPackageDetailService {
@Override
public List<InspectionPackageDetail> selectDetailsByPackageId(String packageId) {
public List<InspectionPackageDetail> selectDetailsByPackageId(Long packageId) {
return this.baseMapper.selectByPackageId(packageId);
}
@Override
@Transactional(rollbackFor = Exception.class)
public Map<String, Integer> batchSaveDetails(String packageId, List<InspectionPackageDetail> details) {
public Map<String, Integer> batchSaveDetails(Long packageId, List<InspectionPackageDetail> details) {
Map<String, Integer> result = new HashMap<>();
int successCount = 0;
int failCount = 0;
@@ -115,7 +115,7 @@ public class InspectionPackageDetailServiceImpl extends ServiceImpl<InspectionPa
}
@Override
public int deleteByPackageId(String packageId) {
public int deleteByPackageId(Long packageId) {
return this.baseMapper.deleteByPackageId(packageId);
}

View File

@@ -24,12 +24,12 @@ import java.util.List;
public class InspectionPackageServiceImpl extends ServiceImpl<InspectionPackageMapper, InspectionPackage> implements IInspectionPackageService {
@Override
public boolean checkPackageNameUnique(String packageName, String orgName, String excludeId) {
public boolean checkPackageNameUnique(String packageName, String orgName, Long excludeId) {
QueryWrapper<InspectionPackage> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("package_name", packageName)
.eq("org_name", orgName)
.eq("del_flag", false);
if (StringUtils.hasText(excludeId)) {
if (excludeId != null) {
queryWrapper.ne("basic_information_id", excludeId);
}
return this.count(queryWrapper) == 0;
@@ -49,6 +49,12 @@ public class InspectionPackageServiceImpl extends ServiceImpl<InspectionPackageM
if (inspectionPackage.getIsDisabled() != null) {
queryWrapper.eq("is_disabled", inspectionPackage.getIsDisabled());
}
if (StringUtils.hasText(inspectionPackage.getDepartment())) {
queryWrapper.eq("department", inspectionPackage.getDepartment());
}
if (StringUtils.hasText(inspectionPackage.getPackageCategory())) {
queryWrapper.eq("package_category", inspectionPackage.getPackageCategory());
}
// 默认只查询未删除的记录
queryWrapper.eq("del_flag", false);
@@ -58,14 +64,16 @@ public class InspectionPackageServiceImpl extends ServiceImpl<InspectionPackageM
if (pageNum != null && pageSize != null) {
Page<InspectionPackage> page = new Page<>(pageNum, pageSize);
return this.page(page, queryWrapper).getRecords();
Page<InspectionPackage> resultPage = this.page(page, queryWrapper);
// 将Page对象存储到ThreadLocal中以便Controller获取total
return resultPage.getRecords();
} else {
return this.list(queryWrapper);
}
}
@Override
public InspectionPackage selectPackageById(String packageId) {
public InspectionPackage selectPackageById(Long packageId) {
return this.getById(packageId);
}
@@ -110,7 +118,7 @@ public class InspectionPackageServiceImpl extends ServiceImpl<InspectionPackageM
}
@Override
public boolean deletePackage(String packageId) {
public boolean deletePackage(Long packageId) {
// 逻辑删除
InspectionPackage inspectionPackage = new InspectionPackage();
inspectionPackage.setBasicInformationId(packageId);