Fix Bug #576: AI修复
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package com.openhis.web.inpatient.mapper;
|
||||
|
||||
import com.openhis.web.inpatient.entity.InspectionApply;
|
||||
import com.openhis.web.inpatient.entity.InspectionApplyItem;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 检验申请数据库操作 Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface InspectionApplyMapper {
|
||||
|
||||
@Insert("INSERT INTO his_inspection_apply (patient_id, symptoms, signs, status, create_time) " +
|
||||
"VALUES (#{patientId}, #{symptoms}, #{signs}, #{status}, #{createTime})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(InspectionApply apply);
|
||||
|
||||
@Update("UPDATE his_inspection_apply SET symptoms = #{symptoms}, signs = #{signs}, update_time = #{updateTime} WHERE id = #{id}")
|
||||
int updateById(InspectionApply apply);
|
||||
|
||||
@Select("SELECT id, patient_id, symptoms, signs, status, create_time FROM his_inspection_apply WHERE id = #{id}")
|
||||
InspectionApply selectById(@Param("id") Long id);
|
||||
|
||||
@Insert("INSERT INTO his_inspection_apply_item (apply_id, item_code, item_name, price, quantity) " +
|
||||
"VALUES (#{applyId}, #{itemCode}, #{itemName}, #{price}, #{quantity})")
|
||||
int insertItem(InspectionApplyItem item);
|
||||
|
||||
@Delete("DELETE FROM his_inspection_apply_item WHERE apply_id = #{applyId}")
|
||||
int deleteItemsByApplyId(@Param("applyId") Long applyId);
|
||||
|
||||
/**
|
||||
* Bug #576 Fix: 新增根据申请单ID查询明细项目的方法
|
||||
* 解决编辑时右侧“已选择”列表回显为空的问题
|
||||
*/
|
||||
@Select("SELECT id, apply_id, item_code, item_name, price, quantity FROM his_inspection_apply_item WHERE apply_id = #{applyId}")
|
||||
List<InspectionApplyItem> selectItemsByApplyId(@Param("applyId") Long applyId);
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.openhis.web.inpatient.service;
|
||||
|
||||
import com.openhis.web.inpatient.dto.InspectionApplyDTO;
|
||||
import com.openhis.web.inpatient.entity.InspectionApply;
|
||||
import com.openhis.web.inpatient.entity.InspectionApplyItem;
|
||||
import com.openhis.web.inpatient.mapper.InspectionApplyMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 住院检验申请服务实现
|
||||
*/
|
||||
@Service
|
||||
public class InspectionApplyServiceImpl implements InspectionApplyService {
|
||||
|
||||
private final InspectionApplyMapper inspectionApplyMapper;
|
||||
|
||||
public InspectionApplyServiceImpl(InspectionApplyMapper inspectionApplyMapper) {
|
||||
this.inspectionApplyMapper = inspectionApplyMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean createApply(InspectionApplyDTO dto) {
|
||||
InspectionApply apply = new InspectionApply();
|
||||
apply.setPatientId(dto.getPatientId());
|
||||
apply.setSymptoms(dto.getSymptoms());
|
||||
apply.setSigns(dto.getSigns());
|
||||
apply.setStatus("PENDING_SIGN");
|
||||
apply.setCreateTime(java.time.LocalDateTime.now());
|
||||
inspectionApplyMapper.insert(apply);
|
||||
|
||||
if (dto.getItems() != null && !dto.getItems().isEmpty()) {
|
||||
for (InspectionApplyItem item : dto.getItems()) {
|
||||
item.setApplyId(apply.getId());
|
||||
inspectionApplyMapper.insertItem(item);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bug #576 Fix: 获取检验申请单详情(含关联明细项目)
|
||||
* 原逻辑仅查询主表,导致编辑弹窗右侧“已选择”列表无数据。
|
||||
* 现补充明细查询并注入 DTO 返回。
|
||||
*/
|
||||
@Override
|
||||
public InspectionApplyDTO getApplyById(Long id) {
|
||||
InspectionApply apply = inspectionApplyMapper.selectById(id);
|
||||
if (apply == null) {
|
||||
throw new IllegalArgumentException("检验申请单不存在");
|
||||
}
|
||||
|
||||
InspectionApplyDTO dto = new InspectionApplyDTO();
|
||||
dto.setId(apply.getId());
|
||||
dto.setPatientId(apply.getPatientId());
|
||||
dto.setSymptoms(apply.getSymptoms());
|
||||
dto.setSigns(apply.getSigns());
|
||||
dto.setStatus(apply.getStatus());
|
||||
dto.setCreateTime(apply.getCreateTime());
|
||||
|
||||
// 修复点:查询并绑定关联的检验项目明细
|
||||
List<InspectionApplyItem> items = inspectionApplyMapper.selectItemsByApplyId(id);
|
||||
dto.setItems(items);
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean updateApply(InspectionApplyDTO dto) {
|
||||
InspectionApply apply = new InspectionApply();
|
||||
apply.setId(dto.getId());
|
||||
apply.setSymptoms(dto.getSymptoms());
|
||||
apply.setSigns(dto.getSigns());
|
||||
apply.setUpdateTime(java.time.LocalDateTime.now());
|
||||
inspectionApplyMapper.updateById(apply);
|
||||
|
||||
// 简化处理:实际业务需对比差异进行增删改,此处仅演示核心修复逻辑
|
||||
if (dto.getItems() != null) {
|
||||
inspectionApplyMapper.deleteItemsByApplyId(dto.getId());
|
||||
for (InspectionApplyItem item : dto.getItems()) {
|
||||
item.setApplyId(dto.getId());
|
||||
inspectionApplyMapper.insertItem(item);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user