套餐设置功能前后端内容基本完成(细节未处理)

This commit is contained in:
2025-12-25 11:12:56 +08:00
parent 32d1673667
commit 55b3dfc077
12 changed files with 1380 additions and 25 deletions

View File

@@ -0,0 +1,254 @@
package com.openhis.web.lab.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.core.common.core.controller.BaseController;
import com.core.common.core.domain.AjaxResult;
import com.core.common.core.page.TableDataInfo;
import com.openhis.lab.domain.InspectionPackage;
import com.openhis.lab.domain.InspectionPackageDetail;
import com.openhis.lab.service.IInspectionPackageDetailService;
import com.openhis.lab.service.IInspectionPackageService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.support.TransactionTemplate;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 检验套餐管理Controller
*
* @author system
* @date 2025-12-25
*/
@RestController
@RequestMapping("/system/inspection-package")
@Slf4j
@AllArgsConstructor
public class InspectionPackageController extends BaseController {
private final IInspectionPackageService inspectionPackageService;
private final IInspectionPackageDetailService inspectionPackageDetailService;
private final TransactionTemplate transactionTemplate;
/**
* 新增检验套餐基本信息
*/
@PostMapping
public AjaxResult add(@RequestBody InspectionPackage inspectionPackage) {
// 校验套餐名称唯一性
if (!inspectionPackageService.checkPackageNameUnique(inspectionPackage.getPackageName(),
inspectionPackage.getOrgName(), null)) {
return AjaxResult.error("套餐名称已存在");
}
// 校验套餐类别(固定为"检验套餐"
if (!"检验套餐".equals(inspectionPackage.getPackageCategory())) {
inspectionPackage.setPackageCategory("检验套餐");
}
try {
boolean result = inspectionPackageService.insertPackage(inspectionPackage);
if (result) {
log.info("新增检验套餐成功packageName={}, basicInformationId={}",
inspectionPackage.getPackageName(), inspectionPackage.getBasicInformationId());
return AjaxResult.success()
.put("packageId", inspectionPackage.getBasicInformationId()) // 保持向后兼容
.put("basicInformationId", inspectionPackage.getBasicInformationId())
.put("id", inspectionPackage.getBasicInformationId());
} else {
return AjaxResult.error("新增失败");
}
} catch (Exception e) {
log.error("新增检验套餐失败packageName={}, error={}",
inspectionPackage.getPackageName(), e.getMessage(), e);
return AjaxResult.error("新增失败:" + e.getMessage());
}
}
/**
* 修改检验套餐基本信息
*/
@PutMapping
public AjaxResult edit(@RequestBody InspectionPackage inspectionPackage) {
// 校验套餐是否存在
InspectionPackage existing = inspectionPackageService.selectPackageById(inspectionPackage.getBasicInformationId());
if (existing == null) {
return AjaxResult.error("套餐不存在");
}
// 校验套餐名称唯一性
if (!inspectionPackageService.checkPackageNameUnique(inspectionPackage.getPackageName(),
inspectionPackage.getOrgName(), inspectionPackage.getBasicInformationId())) {
return AjaxResult.error("套餐名称已存在");
}
try {
boolean result = inspectionPackageService.updatePackage(inspectionPackage);
if (result) {
log.info("修改检验套餐成功basicInformationId={}, packageName={}",
inspectionPackage.getBasicInformationId(), inspectionPackage.getPackageName());
return AjaxResult.success();
} else {
return AjaxResult.error("修改失败");
}
} catch (Exception e) {
log.error("修改检验套餐失败basicInformationId={}, error={}",
inspectionPackage.getBasicInformationId(), e.getMessage(), e);
return AjaxResult.error("修改失败:" + e.getMessage());
}
}
/**
* 查询检验套餐详情
*/
@GetMapping("/{basicInformationId}")
public AjaxResult getInfo(@PathVariable String basicInformationId) {
InspectionPackage inspectionPackage = inspectionPackageService.selectPackageById(basicInformationId);
if (inspectionPackage == null) {
return AjaxResult.error("套餐不存在");
}
return AjaxResult.success(inspectionPackage);
}
/**
* 查询检验套餐列表
*/
@GetMapping("/list")
public TableDataInfo list(InspectionPackage inspectionPackage,
@RequestParam(required = false) Integer pageNum,
@RequestParam(required = false) Integer pageSize) {
// 设置默认分页参数
if (pageNum == null) pageNum = 1;
if (pageSize == null) pageSize = 10;
List<InspectionPackage> list = inspectionPackageService.selectPackageList(inspectionPackage, pageNum, pageSize);
return getDataTable(list);
}
/**
* 删除检验套餐
*/
@DeleteMapping("/{basicInformationId}")
public AjaxResult remove(@PathVariable String basicInformationId) {
// 校验套餐是否存在
InspectionPackage existing = inspectionPackageService.selectPackageById(basicInformationId);
if (existing == null) {
return AjaxResult.error("套餐不存在");
}
try {
boolean result = inspectionPackageService.deletePackage(basicInformationId);
if (result) {
log.info("删除检验套餐成功basicInformationId={}", basicInformationId);
return AjaxResult.success("删除成功");
} else {
return AjaxResult.error("删除失败");
}
} catch (Exception e) {
log.error("删除检验套餐失败basicInformationId={}, error={}", basicInformationId, e.getMessage(), e);
return AjaxResult.error("删除失败:" + e.getMessage());
}
}
// ============ 明细数据管理接口 ============
/**
* 批量保存检验套餐明细
*/
@PostMapping("/details/batch")
public AjaxResult batchSaveDetails(@RequestBody BatchSaveDetailRequest request) {
// 校验套餐是否存在
InspectionPackage inspectionPackage = inspectionPackageService.selectPackageById(request.getBasicInformationId());
if (inspectionPackage == null) {
return AjaxResult.error("套餐不存在");
}
try {
var result = inspectionPackageDetailService.batchSaveDetails(request.getBasicInformationId(), request.getDetails());
log.info("批量保存明细成功basicInformationId={}, successCount={}, failCount={}",
request.getBasicInformationId(), result.get("successCount"), result.get("failCount"));
return AjaxResult.success("批量保存成功").put("data", result);
} catch (Exception e) {
log.error("批量保存明细失败basicInformationId={}, error={}", request.getBasicInformationId(), e.getMessage(), e);
return AjaxResult.error("批量保存失败:" + e.getMessage());
}
}
/**
* 查询检验套餐明细列表
*/
@GetMapping("/details/{basicInformationId}")
public AjaxResult getDetails(@PathVariable String basicInformationId) {
// 校验套餐是否存在
InspectionPackage inspectionPackage = inspectionPackageService.selectPackageById(basicInformationId);
if (inspectionPackage == null) {
return AjaxResult.error("套餐不存在");
}
List<InspectionPackageDetail> details = inspectionPackageDetailService.selectDetailsByPackageId(basicInformationId);
return AjaxResult.success(details);
}
/**
* 保存单个检验套餐明细
*/
@PostMapping("/details")
public AjaxResult saveDetail(@RequestBody InspectionPackageDetail detail) {
// 校验套餐是否存在
InspectionPackage inspectionPackage = inspectionPackageService.selectPackageById(detail.getBasicInformationId());
if (inspectionPackage == null) {
return AjaxResult.error("套餐不存在");
}
try {
boolean result = inspectionPackageDetailService.saveDetail(detail);
if (result) {
log.info("保存单个明细成功detailId={}", detail.getDetailId());
return AjaxResult.success("保存成功").put("detailId", detail.getDetailId());
} else {
return AjaxResult.error("保存失败");
}
} catch (Exception e) {
log.error("保存单个明细失败error={}", e.getMessage(), e);
return AjaxResult.error("保存失败:" + e.getMessage());
}
}
/**
* 删除检验套餐明细
*/
@DeleteMapping("/details")
public AjaxResult deleteDetails(@RequestBody DeleteDetailRequest request) {
if (request.getDetailIds() == null || request.getDetailIds().isEmpty()) {
return AjaxResult.error("明细ID不能为空");
}
try {
int deletedCount = inspectionPackageDetailService.deleteDetails(request.getDetailIds());
log.info("删除明细成功detailIds={}, deletedCount={}", request.getDetailIds(), deletedCount);
return AjaxResult.success("删除成功");
} catch (Exception e) {
log.error("删除明细失败detailIds={}, error={}", request.getDetailIds(), e.getMessage(), e);
return AjaxResult.error("删除失败:" + e.getMessage());
}
}
// 请求DTO类
public static class BatchSaveDetailRequest {
private String basicInformationId;
private List<InspectionPackageDetail> details;
public String getBasicInformationId() { return basicInformationId; }
public void setBasicInformationId(String basicInformationId) { this.basicInformationId = basicInformationId; }
public List<InspectionPackageDetail> getDetails() { return details; }
public void setDetails(List<InspectionPackageDetail> details) { this.details = details; }
}
public static class DeleteDetailRequest {
private List<String> detailIds;
public List<String> getDetailIds() { return detailIds; }
public void setDetailIds(List<String> detailIds) { this.detailIds = detailIds; }
}
}

View File

@@ -0,0 +1,101 @@
package com.openhis.lab.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* 检验套餐基本信息
*
* @author system
* @date 2025-12-25
*/
@Data
@Accessors(chain = true)
@TableName(value = "inspection_basic_information", autoResultMap = true)
public class InspectionPackage {
private static final long serialVersionUID = 1L;
/** 套餐ID */
@TableId(type = IdType.ASSIGN_ID)
@JsonProperty("packageId") // 保持向后兼容
private String basicInformationId;
/** 套餐类别,固定值:"检验套餐" */
private String packageCategory;
/** 套餐级别:全院套餐/科室套餐/个人套餐 */
private String packageLevel;
/** 套餐名称 */
private String packageName;
/** 科室名称 */
private String department;
/** 科室ID */
private String departmentId;
/** 用户ID */
private String userId;
/** 折扣百分比默认0 */
private BigDecimal discount;
/** 是否停用默认false */
@TableField("is_disabled")
private Boolean isDisabled;
/** 显示套餐名默认true */
@TableField("show_package_name")
private Boolean showPackageName;
/** 生成服务费默认true */
@TableField("generate_service_fee")
private Boolean generateServiceFee;
/** 套餐价格启用默认true */
@TableField("enable_package_price")
private Boolean enablePackagePrice;
/** 套餐金额默认0.00 */
private BigDecimal packageAmount;
/** 服务费默认0.00 */
private BigDecimal serviceFee;
/** LIS分组ID */
private String lisGroup;
/** 血量 */
private String bloodVolume;
/** 备注 */
private String remarks;
/** 卫生机构名称 */
private String orgName;
/** 制单人 */
private String createBy;
/** 创建时间 */
@TableField("create_time")
private LocalDateTime createTime;
/** 更新时间 */
@TableField("update_time")
private LocalDateTime updateTime;
/** 删除标志false-正常true-删除) */
@TableLogic(value = "false", delval = "true")
private Boolean delFlag;
}

View File

@@ -0,0 +1,85 @@
package com.openhis.lab.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* 检验套餐明细
*
* @author system
* @date 2025-12-25
*/
@Data
@Accessors(chain = true)
@TableName(value = "inspection_package_detail", autoResultMap = true)
public class InspectionPackageDetail {
private static final long serialVersionUID = 1L;
/** 明细ID */
@TableId(type = IdType.ASSIGN_ID)
private String detailId;
/** 套餐ID */
@JsonProperty("packageId") // 保持向后兼容
private String basicInformationId;
/** 套餐名称 */
private String packageName;
/** 项目名称 */
private String itemName;
/** 剂量 */
private String dosage;
/** 途径 */
private String route;
/** 频次 */
private String frequency;
/** 天数 */
private Integer days;
/** 数量默认1 */
private Integer quantity;
/** 单位 */
private String unit;
/** 单价 */
private BigDecimal unitPrice;
/** 金额 */
private BigDecimal amount;
/** 服务费默认0.00 */
private BigDecimal serviceFee;
/** 总金额 */
private BigDecimal totalAmount;
/** 产地 */
private String origin;
/** 创建时间 */
@TableField("create_time")
private LocalDateTime createTime;
/** 更新时间 */
@TableField("update_time")
private LocalDateTime updateTime;
/** 删除标志false-正常true-删除) */
@TableLogic(value = "false", delval = "true")
private Boolean delFlag;
}

View File

@@ -0,0 +1,38 @@
package com.openhis.lab.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.openhis.lab.domain.InspectionPackageDetail;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 检验套餐明细Mapper接口
*
* @author system
* @date 2025-12-25
*/
@Mapper
public interface InspectionPackageDetailMapper extends BaseMapper<InspectionPackageDetail> {
/**
* 根据套餐ID批量删除明细数据
* @param packageId 套餐ID
* @return 删除的记录数
*/
int deleteByPackageId(String packageId);
/**
* 根据套餐ID查询明细列表
* @param packageId 套餐ID
* @return 明细列表
*/
List<InspectionPackageDetail> selectByPackageId(String packageId);
/**
* 批量插入明细数据
* @param details 明细数据列表
* @return 插入的记录数
*/
int batchInsert(List<InspectionPackageDetail> details);
}

View File

@@ -0,0 +1,16 @@
package com.openhis.lab.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.openhis.lab.domain.InspectionPackage;
import org.apache.ibatis.annotations.Mapper;
/**
* 检验套餐Mapper接口
*
* @author system
* @date 2025-12-25
*/
@Mapper
public interface InspectionPackageMapper extends BaseMapper<InspectionPackage> {
}

View File

@@ -0,0 +1,58 @@
package com.openhis.lab.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.openhis.lab.domain.InspectionPackageDetail;
import java.util.List;
/**
* 检验套餐明细Service接口
*
* @author system
* @date 2025-12-25
*/
public interface IInspectionPackageDetailService extends IService<InspectionPackageDetail> {
/**
* 根据套餐ID查询明细列表
* @param packageId 套餐ID
* @return 明细列表
*/
List<InspectionPackageDetail> selectDetailsByPackageId(String packageId);
/**
* 批量保存明细数据
* @param packageId 套餐ID
* @param details 明细数据列表
* @return 保存结果 {successCount: 成功数量, failCount: 失败数量}
*/
java.util.Map<String, Integer> batchSaveDetails(String packageId, List<InspectionPackageDetail> details);
/**
* 保存单个明细数据
* @param detail 明细数据
* @return 结果
*/
boolean saveDetail(InspectionPackageDetail detail);
/**
* 批量删除明细数据
* @param detailIds 明细ID数组
* @return 删除数量
*/
int deleteDetails(List<String> detailIds);
/**
* 根据套餐ID删除所有明细数据
* @param packageId 套餐ID
* @return 删除数量
*/
int deleteByPackageId(String packageId);
/**
* 计算明细数据的总金额和服务费
* @param details 明细数据列表
* @return {totalAmount: 总金额, totalServiceFee: 总服务费}
*/
java.util.Map<String, java.math.BigDecimal> calculateTotalAmount(List<InspectionPackageDetail> details);
}

View File

@@ -0,0 +1,61 @@
package com.openhis.lab.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.openhis.lab.domain.InspectionPackage;
import java.util.List;
/**
* 检验套餐Service接口
*
* @author system
* @date 2025-12-25
*/
public interface IInspectionPackageService extends IService<InspectionPackage> {
/**
* 校验套餐名称唯一性
* @param packageName 套餐名称
* @param orgName 机构名称
* @param excludeId 排除的ID用于更新时
* @return true-唯一false-不唯一
*/
boolean checkPackageNameUnique(String packageName, String orgName, String excludeId);
/**
* 根据条件查询套餐列表(分页)
* @param inspectionPackage 查询条件
* @param pageNum 页码
* @param pageSize 每页数量
* @return 套餐列表
*/
List<InspectionPackage> selectPackageList(InspectionPackage inspectionPackage, Integer pageNum, Integer pageSize);
/**
* 根据套餐ID查询套餐详情
* @param packageId 套餐ID
* @return 套餐信息
*/
InspectionPackage selectPackageById(String packageId);
/**
* 新增检验套餐
* @param inspectionPackage 套餐信息
* @return 结果
*/
boolean insertPackage(InspectionPackage inspectionPackage);
/**
* 修改检验套餐
* @param inspectionPackage 套餐信息
* @return 结果
*/
boolean updatePackage(InspectionPackage inspectionPackage);
/**
* 删除检验套餐
* @param packageId 套餐ID
* @return 结果
*/
boolean deletePackage(String packageId);
}

View File

@@ -0,0 +1,143 @@
package com.openhis.lab.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.openhis.lab.domain.InspectionPackageDetail;
import com.openhis.lab.mapper.InspectionPackageDetailMapper;
import com.openhis.lab.service.IInspectionPackageDetailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 检验套餐明细Service业务层处理
*
* @author system
* @date 2025-12-25
*/
@Slf4j
@Service
public class InspectionPackageDetailServiceImpl extends ServiceImpl<InspectionPackageDetailMapper, InspectionPackageDetail> implements IInspectionPackageDetailService {
@Override
public List<InspectionPackageDetail> selectDetailsByPackageId(String packageId) {
return this.baseMapper.selectByPackageId(packageId);
}
@Override
@Transactional(rollbackFor = Exception.class)
public Map<String, Integer> batchSaveDetails(String packageId, List<InspectionPackageDetail> details) {
Map<String, Integer> result = new HashMap<>();
int successCount = 0;
int failCount = 0;
try {
// 1. 先删除该套餐下的所有旧明细数据
int deletedCount = this.baseMapper.deleteByPackageId(packageId);
log.info("删除套餐{}的旧明细数据{}条", packageId, deletedCount);
// 2. 批量插入新的明细数据
if (!CollectionUtils.isEmpty(details)) {
// 设置套餐ID和创建时间
for (InspectionPackageDetail detail : details) {
detail.setBasicInformationId(packageId);
detail.setCreateTime(LocalDateTime.now());
detail.setUpdateTime(LocalDateTime.now());
// 设置默认值
if (detail.getQuantity() == null) {
detail.setQuantity(1);
}
if (detail.getServiceFee() == null) {
detail.setServiceFee(BigDecimal.ZERO);
}
if (detail.getTotalAmount() == null) {
// 计算总金额 = 金额 + 服务费
BigDecimal totalAmount = detail.getAmount() != null ? detail.getAmount() : BigDecimal.ZERO;
totalAmount = totalAmount.add(detail.getServiceFee());
detail.setTotalAmount(totalAmount);
}
}
// 批量插入
int insertedCount = this.baseMapper.batchInsert(details);
successCount = insertedCount;
log.info("批量插入套餐{}的新明细数据{}条", packageId, insertedCount);
}
} catch (Exception e) {
log.error("批量保存明细数据失败packageId={}, error={}", packageId, e.getMessage(), e);
failCount = details != null ? details.size() : 0;
throw e; // 让事务回滚
}
result.put("successCount", successCount);
result.put("failCount", failCount);
return result;
}
@Override
public boolean saveDetail(InspectionPackageDetail detail) {
// 设置默认值
if (detail.getQuantity() == null) {
detail.setQuantity(1);
}
if (detail.getServiceFee() == null) {
detail.setServiceFee(BigDecimal.ZERO);
}
if (detail.getTotalAmount() == null) {
// 计算总金额 = 金额 + 服务费
BigDecimal totalAmount = detail.getAmount() != null ? detail.getAmount() : BigDecimal.ZERO;
totalAmount = totalAmount.add(detail.getServiceFee());
detail.setTotalAmount(totalAmount);
}
detail.setCreateTime(LocalDateTime.now());
detail.setUpdateTime(LocalDateTime.now());
return this.save(detail);
}
@Override
public int deleteDetails(List<String> detailIds) {
if (CollectionUtils.isEmpty(detailIds)) {
return 0;
}
// 逻辑删除
return this.baseMapper.deleteBatchIds(detailIds);
}
@Override
public int deleteByPackageId(String packageId) {
return this.baseMapper.deleteByPackageId(packageId);
}
@Override
public Map<String, BigDecimal> calculateTotalAmount(List<InspectionPackageDetail> details) {
Map<String, BigDecimal> result = new HashMap<>();
BigDecimal totalAmount = BigDecimal.ZERO;
BigDecimal totalServiceFee = BigDecimal.ZERO;
if (!CollectionUtils.isEmpty(details)) {
for (InspectionPackageDetail detail : details) {
if (detail.getAmount() != null) {
totalAmount = totalAmount.add(detail.getAmount());
}
if (detail.getServiceFee() != null) {
totalServiceFee = totalServiceFee.add(detail.getServiceFee());
}
}
}
result.put("totalAmount", totalAmount);
result.put("totalServiceFee", totalServiceFee);
return result;
}
}

View File

@@ -0,0 +1,121 @@
package com.openhis.lab.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.openhis.lab.domain.InspectionPackage;
import com.openhis.lab.mapper.InspectionPackageMapper;
import com.openhis.lab.service.IInspectionPackageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.util.List;
/**
* 检验套餐Service业务层处理
*
* @author system
* @date 2025-12-25
*/
@Slf4j
@Service
public class InspectionPackageServiceImpl extends ServiceImpl<InspectionPackageMapper, InspectionPackage> implements IInspectionPackageService {
@Override
public boolean checkPackageNameUnique(String packageName, String orgName, String excludeId) {
QueryWrapper<InspectionPackage> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("package_name", packageName)
.eq("org_name", orgName)
.eq("del_flag", false);
if (StringUtils.hasText(excludeId)) {
queryWrapper.ne("basic_information_id", excludeId);
}
return this.count(queryWrapper) == 0;
}
@Override
public List<InspectionPackage> selectPackageList(InspectionPackage inspectionPackage, Integer pageNum, Integer pageSize) {
QueryWrapper<InspectionPackage> queryWrapper = new QueryWrapper<>();
// 构建查询条件
if (StringUtils.hasText(inspectionPackage.getPackageName())) {
queryWrapper.like("package_name", inspectionPackage.getPackageName());
}
if (StringUtils.hasText(inspectionPackage.getPackageLevel())) {
queryWrapper.eq("package_level", inspectionPackage.getPackageLevel());
}
if (inspectionPackage.getIsDisabled() != null) {
queryWrapper.eq("is_disabled", inspectionPackage.getIsDisabled());
}
// 默认只查询未删除的记录
queryWrapper.eq("del_flag", false);
// 排序
queryWrapper.orderByDesc("create_time");
if (pageNum != null && pageSize != null) {
Page<InspectionPackage> page = new Page<>(pageNum, pageSize);
return this.page(page, queryWrapper).getRecords();
} else {
return this.list(queryWrapper);
}
}
@Override
public InspectionPackage selectPackageById(String packageId) {
return this.getById(packageId);
}
@Override
public boolean insertPackage(InspectionPackage inspectionPackage) {
// 设置默认值
if (inspectionPackage.getDiscount() == null) {
inspectionPackage.setDiscount(java.math.BigDecimal.ZERO);
}
if (inspectionPackage.getIsDisabled() == null) {
inspectionPackage.setIsDisabled(false);
}
if (inspectionPackage.getShowPackageName() == null) {
inspectionPackage.setShowPackageName(true);
}
if (inspectionPackage.getGenerateServiceFee() == null) {
inspectionPackage.setGenerateServiceFee(true);
}
if (inspectionPackage.getEnablePackagePrice() == null) {
inspectionPackage.setEnablePackagePrice(true);
}
if (inspectionPackage.getPackageAmount() == null) {
inspectionPackage.setPackageAmount(java.math.BigDecimal.ZERO);
}
if (inspectionPackage.getServiceFee() == null) {
inspectionPackage.setServiceFee(java.math.BigDecimal.ZERO);
}
// 设置创建时间
inspectionPackage.setCreateTime(LocalDateTime.now());
inspectionPackage.setUpdateTime(LocalDateTime.now());
return this.save(inspectionPackage);
}
@Override
public boolean updatePackage(InspectionPackage inspectionPackage) {
// 设置更新时间
inspectionPackage.setUpdateTime(LocalDateTime.now());
return this.updateById(inspectionPackage);
}
@Override
public boolean deletePackage(String packageId) {
// 逻辑删除
InspectionPackage inspectionPackage = new InspectionPackage();
inspectionPackage.setBasicInformationId(packageId);
inspectionPackage.setUpdateTime(LocalDateTime.now());
return this.removeById(packageId);
}
}

View File

@@ -0,0 +1,83 @@
<?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="com.openhis.lab.mapper.InspectionPackageDetailMapper">
<!-- 根据套餐ID删除明细数据 -->
<delete id="deleteByPackageId">
DELETE FROM inspection_package_detail
WHERE basic_information_id = #{packageId} AND del_flag = false
</delete>
<!-- 根据套餐ID查询明细列表 -->
<select id="selectByPackageId" resultType="com.openhis.lab.domain.InspectionPackageDetail">
SELECT
detail_id,
basic_information_id,
package_name,
item_name,
dosage,
route,
frequency,
days,
quantity,
unit,
unit_price,
amount,
service_fee,
total_amount,
origin,
create_time,
update_time,
del_flag
FROM inspection_package_detail
WHERE basic_information_id = #{packageId} AND del_flag = false
ORDER BY create_time ASC
</select>
<!-- 批量插入明细数据 -->
<insert id="batchInsert">
INSERT INTO inspection_package_detail (
detail_id,
basic_information_id,
package_name,
item_name,
dosage,
route,
frequency,
days,
quantity,
unit,
unit_price,
amount,
service_fee,
total_amount,
origin,
create_time,
update_time,
del_flag
) VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.detailId},
#{item.basicInformationId},
#{item.packageName},
#{item.itemName},
#{item.dosage},
#{item.route},
#{item.frequency},
#{item.days},
#{item.quantity},
#{item.unit},
#{item.unitPrice},
#{item.amount},
#{item.serviceFee},
#{item.totalAmount},
#{item.origin},
#{item.createTime},
#{item.updateTime},
#{item.delFlag}
)
</foreach>
</insert>
</mapper>