套餐设置套餐管理完善
This commit is contained in:
@@ -51,10 +51,11 @@ public class InspectionPackageController extends BaseController {
|
||||
if (result) {
|
||||
log.info("新增检验套餐成功:packageName={}, basicInformationId={}",
|
||||
inspectionPackage.getPackageName(), inspectionPackage.getBasicInformationId());
|
||||
String idStr = inspectionPackage.getBasicInformationId() == null ? null : String.valueOf(inspectionPackage.getBasicInformationId());
|
||||
return AjaxResult.success()
|
||||
.put("packageId", inspectionPackage.getBasicInformationId()) // 保持向后兼容
|
||||
.put("basicInformationId", inspectionPackage.getBasicInformationId())
|
||||
.put("id", inspectionPackage.getBasicInformationId());
|
||||
.put("packageId", idStr) // 保持向后兼容(前端按字符串处理,避免精度丢失)
|
||||
.put("basicInformationId", idStr)
|
||||
.put("id", idStr);
|
||||
} else {
|
||||
return AjaxResult.error("新增失败");
|
||||
}
|
||||
@@ -102,7 +103,7 @@ public class InspectionPackageController extends BaseController {
|
||||
* 查询检验套餐详情
|
||||
*/
|
||||
@GetMapping("/{basicInformationId}")
|
||||
public AjaxResult getInfo(@PathVariable String basicInformationId) {
|
||||
public AjaxResult getInfo(@PathVariable Long basicInformationId) {
|
||||
InspectionPackage inspectionPackage = inspectionPackageService.selectPackageById(basicInformationId);
|
||||
if (inspectionPackage == null) {
|
||||
return AjaxResult.error("套餐不存在");
|
||||
@@ -121,15 +122,57 @@ public class InspectionPackageController extends BaseController {
|
||||
if (pageNum == null) pageNum = 1;
|
||||
if (pageSize == null) pageSize = 10;
|
||||
|
||||
List<InspectionPackage> list = inspectionPackageService.selectPackageList(inspectionPackage, pageNum, pageSize);
|
||||
return getDataTable(list);
|
||||
// 使用MyBatis Plus分页查询
|
||||
com.baomidou.mybatisplus.extension.plugins.pagination.Page<InspectionPackage> page =
|
||||
new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(pageNum, pageSize);
|
||||
|
||||
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<InspectionPackage> queryWrapper =
|
||||
new com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<>();
|
||||
|
||||
// 构建查询条件
|
||||
if (inspectionPackage != null) {
|
||||
if (inspectionPackage.getPackageName() != null && !inspectionPackage.getPackageName().isEmpty()) {
|
||||
queryWrapper.like("package_name", inspectionPackage.getPackageName());
|
||||
}
|
||||
if (inspectionPackage.getPackageLevel() != null && !inspectionPackage.getPackageLevel().isEmpty()) {
|
||||
queryWrapper.eq("package_level", inspectionPackage.getPackageLevel());
|
||||
}
|
||||
if (inspectionPackage.getDepartment() != null && !inspectionPackage.getDepartment().isEmpty()) {
|
||||
queryWrapper.eq("department", inspectionPackage.getDepartment());
|
||||
}
|
||||
if (inspectionPackage.getPackageCategory() != null && !inspectionPackage.getPackageCategory().isEmpty()) {
|
||||
queryWrapper.eq("package_category", inspectionPackage.getPackageCategory());
|
||||
}
|
||||
if (inspectionPackage.getIsDisabled() != null) {
|
||||
queryWrapper.eq("is_disabled", inspectionPackage.getIsDisabled());
|
||||
}
|
||||
}
|
||||
|
||||
// 默认只查询未删除的记录
|
||||
queryWrapper.eq("del_flag", false);
|
||||
|
||||
// 排序
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
|
||||
// 执行分页查询
|
||||
com.baomidou.mybatisplus.extension.plugins.pagination.Page<InspectionPackage> resultPage =
|
||||
inspectionPackageService.page(page, queryWrapper);
|
||||
|
||||
// 构建返回结果
|
||||
TableDataInfo dataTable = new TableDataInfo();
|
||||
dataTable.setCode(com.core.common.constant.HttpStatus.SUCCESS);
|
||||
dataTable.setMsg("查询成功");
|
||||
dataTable.setRows(resultPage.getRecords());
|
||||
dataTable.setTotal(resultPage.getTotal());
|
||||
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除检验套餐
|
||||
*/
|
||||
@DeleteMapping("/{basicInformationId}")
|
||||
public AjaxResult remove(@PathVariable String basicInformationId) {
|
||||
public AjaxResult remove(@PathVariable Long basicInformationId) {
|
||||
// 校验套餐是否存在
|
||||
InspectionPackage existing = inspectionPackageService.selectPackageById(basicInformationId);
|
||||
if (existing == null) {
|
||||
@@ -178,7 +221,7 @@ public class InspectionPackageController extends BaseController {
|
||||
* 查询检验套餐明细列表
|
||||
*/
|
||||
@GetMapping("/details/{basicInformationId}")
|
||||
public AjaxResult getDetails(@PathVariable String basicInformationId) {
|
||||
public AjaxResult getDetails(@PathVariable Long basicInformationId) {
|
||||
// 校验套餐是否存在
|
||||
InspectionPackage inspectionPackage = inspectionPackageService.selectPackageById(basicInformationId);
|
||||
if (inspectionPackage == null) {
|
||||
@@ -235,11 +278,11 @@ public class InspectionPackageController extends BaseController {
|
||||
|
||||
// 请求DTO类
|
||||
public static class BatchSaveDetailRequest {
|
||||
private String basicInformationId;
|
||||
private Long basicInformationId;
|
||||
private List<InspectionPackageDetail> details;
|
||||
|
||||
public String getBasicInformationId() { return basicInformationId; }
|
||||
public void setBasicInformationId(String basicInformationId) { this.basicInformationId = basicInformationId; }
|
||||
public Long getBasicInformationId() { return basicInformationId; }
|
||||
public void setBasicInformationId(Long basicInformationId) { this.basicInformationId = basicInformationId; }
|
||||
public List<InspectionPackageDetail> getDetails() { return details; }
|
||||
public void setDetails(List<InspectionPackageDetail> details) { this.details = details; }
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
/**
|
||||
* 批量插入明细数据
|
||||
|
||||
@@ -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);
|
||||
|
||||
/**
|
||||
* 计算明细数据的总金额和服务费
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -98,6 +98,13 @@ WHERE aci.context_enum = 'ACTIVITY'
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user